Skip to contentSkip to conversation

SPL: Add YMODEM over UART load support

PATCH New Tom Rini 5 participants 15 messages Jan 31, 2012 – Feb 1, 2012

Subsystems (2)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

From: Matt Porter <[email protected]>

Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port.

---
 arch/arm/cpu/armv7/omap-common/Makefile     |    3 +
 arch/arm/cpu/armv7/omap-common/spl.c        |    5 ++
 arch/arm/cpu/armv7/omap-common/spl_ymodem.c |   76 +++++++++++++++++++++++++++
 arch/arm/include/asm/omap_common.h          |    3 +
 common/Makefile                             |    3 +
 lib/Makefile                                |    3 +
 6 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl_ymodem.c
arch/arm/cpu/armv7/omap-common/Makefile +3 -0
index 3f7a0b2..447fcd5 100644
@@ -52,6 +52,9 @@ endif
 ifdef CONFIG_SPL_MMC_SUPPORT
 COBJS	+= spl_mmc.o
 endif
+ifdef CONFIG_SPL_YMODEM_SUPPORT
+COBJS	+= spl_ymodem.o
+endif
 endif
 
 ifndef CONFIG_SPL_BUILD
arch/arm/cpu/armv7/omap-common/spl.c +5 -0
index 9c1f7e3..9018787 100644
@@ -134,6 +134,11 @@ void board_init_r(gd_t *id, ulong dummy)
 		spl_nand_load_image();
 		break;
 #endif
+#ifdef CONFIG_SPL_YMODEM_SUPPORT
+	case BOOT_DEVICE_UART:
+		spl_ymodem_load_image();
+		break;
+#endif
 	default:
 		printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device);
 		hang();
arch/arm/cpu/armv7/omap-common/spl_ymodem.c new file +76 -0

76 lines not on this page · raw message

arch/arm/include/asm/omap_common.h +3 -0
index 34bec45..25f95b4 100644
@@ -99,6 +99,9 @@ void spl_nand_load_image(void);
 /* MMC SPL functions */
 void spl_mmc_load_image(void);
 
+/* YMODEM SPL functions */
+void spl_ymodem_load_image(void);
+
 #ifdef CONFIG_SPL_BOARD_INIT
 void spl_board_init(void);
 #endif
common/Makefile +3 -0
index 2d9ae8c..0189aac 100644
@@ -184,6 +184,9 @@ COBJS-$(CONFIG_UPDATE_TFTP) += update.o
 COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 endif
 
+ifdef CONFIG_SPL_BUILD
+COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
+endif
 COBJS-y += console.o
 COBJS-y += dlmalloc.o
 COBJS-y += memsize.o
lib/Makefile +3 -0
index 35ba7ff..eb60b99 100644
@@ -54,6 +54,9 @@ else
 COBJS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += display_options.o
 endif
 
+ifdef CONFIG_SPL_BUILD
+COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
+endif
 COBJS-y += ctype.o
 COBJS-y += div64.o
 COBJS-y += string.o
Signature · 1 line
1.7.0.4
author
#1 lore raw

PATCH 2/2 SPL: Enable YMODEM support on BeagleBone and AM335x EVM

From: Matt Porter <[email protected]>

---
 include/configs/am335x_evm.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/configs/am335x_evm.h +1 -0
index 2cea1f4..23663de 100644
@@ -136,6 +136,7 @@
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
 #define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_YMODEM_SUPPORT
 #define CONFIG_SPL_LDSCRIPT		"$(CPUDIR)/omap-common/u-boot-spl.lds"
 
 /*
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

In reply to Tom Rini

Hi Tom, Hi Matt,

Quoted 6 lines · Tom Rini

From: Matt Porter <[email protected]>

Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port.

:-) I like this feature!

I tried something similar a few month ago for the da850evm and my own board, it worked but I never had time to finished it and submit it, it was just a hack.

For my tests I used the UART loader utility from TI to load the SPL and then minicom for loading u-boot. Do you have an automated solution for this? Would be nice to have something like this in tools/.

Quoted 6 lines
---
 arch/arm/cpu/armv7/omap-common/Makefile     |    3 +
 arch/arm/cpu/armv7/omap-common/spl.c        |    5 ++
 arch/arm/cpu/armv7/omap-common/spl_ymodem.c |   76

+++++++++++++++++++++++++++

Quoted 6 lines
 arch/arm/include/asm/omap_common.h          |    3 +
 common/Makefile                             |    3 +
 lib/Makefile                                |    3 +
 6 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl_ymodem.c

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/omap-common/spl_ymodem.c

Could this be somewhere where it's accessible for other SoC families like davinci? E.g. We have nand_spl_load.c in drivers/mtd/nand and something similar for SPI flash.

Regards, Christian

Quoted 56 lines

new file mode 100644
index 0000000..47663f7

arch/arm/cpu/armv7/omap-common/spl_ymodem.c new file +51 -0
@@ -0,0 +1,76 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * (C) Copyright 2011
+ * Texas Instruments, <www.ti.com>
+ *
+ * Matt Porter <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <xyzModem.h>
+#include <asm/u-boot.h>
+#include <asm/utils.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/omap_common.h>
+
+#define BUF_SIZE 1024
+
+static int getcymodem(void) {
+       if (tstc())
+               return (getc());
+       return -1;
+}
+
+void spl_ymodem_load_image(void)
+{
+       int size = 0;
+       int err;
+       int res;
+       int ret;
+       connection_info_t info;
+       char buf[BUF_SIZE];
+       ulong store_addr = ~0;

arch/arm/cpu/armv7/omap-common/spl_ymodem.c line 61

Quoted 10 lines
arch/arm/cpu/armv7/omap-common/spl_ymodem.c new file +10 -0
+       ulong addr = 0;
+
+       info.mode = xyzModem_ymodem;
+       ret = xyzModem_stream_open(&info, &err);
+
+       if (!ret) {
+               while ((res =
+                       xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) {
+                       if (addr == 0)
+                               spl_parse_image_header((struct

image_header *)buf);

Quoted 15 lines
arch/arm/cpu/armv7/omap-common/spl_ymodem.c new file +15 -0
+                       store_addr = addr + spl_image.load_addr;
+                       size += res;
+                       addr += res;
+                       memcpy((char *)(store_addr), buf, res);
+               }
+       } else {
+               printf("spl: ymodem err - %s\n", xyzModem_error(err));
+               hang();
+       }
+
+       xyzModem_stream_close(&err);
+       xyzModem_stream_terminate(false, &getcymodem);
+
+       printf("Loaded %d bytes\n", size);
+}
#3 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Quoted 12 lines · Christian Riesch

Hi Tom, Hi Matt,

Quoted 6 lines · Tom Rini

From: Matt Porter <[email protected]>

Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port.

:-) I like this feature!

Quoted 7 lines

I tried something similar a few month ago for the da850evm and my own board, it worked but I never had time to finished it and submit it, it was just a hack.

For my tests I used the UART loader utility from TI to load the SPL and then minicom for loading u-boot. Do you have an automated solution for this? Would be nice to have something like this in tools/.

IIRC the da850evm ROM needs a special tool to load via UART. omap4/5/am33xx ROM does XMODEM for real so 'sx' works fine.

[snip]

Quoted 3 lines

Could this be somewhere where it's accessible for other SoC families like davinci? E.g. We have nand_spl_load.c in drivers/mtd/nand and something similar for SPI flash.

In theory, sure, just need a location to place it at.

Signature · 1 line
Tom
#4 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

In reply to Tom Rini

Dear Tom Rini,

Quoted 6 lines · In message <[email protected]> you wrote:

From: Matt Porter <[email protected]>

Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port.

Does it really make sense to add all kind of bloat to the SPL?

What originally has been designed to be minimal code now start to pull in all kinds of other crap, that has never been designed to run before relocation.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
To be a winner, all you need to give is all you have.
#5 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Quoted 10 lines · Wolfgang Denk

Dear Tom Rini,

Quoted 6 lines · In message <[email protected]> you wrote:

From: Matt Porter <[email protected]>

Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port.

Quoted 5 lines

Does it really make sense to add all kind of bloat to the SPL?

What originally has been designed to be minimal code now start to pull in all kinds of other crap, that has never been designed to run before relocation.

Boards that don't need it can opt out. We use this internally for automated testing of U-Boot on hardware (and I'm setting up the same thing locally).

Signature · 1 line
Tom
#6 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Dear Tom Rini,

Quoted 8 lines · In message <CA+M6bXmKum1B39RVcJ+jgDRmFCFr5sToZYDUVXnM4NfUZ-XQaQ@mail.gmail.com>…
Quoted 4 lines

What originally has been designed to be minimal code now start to pull in all kinds of other crap, that has never been designed to run before relocation.

Boards that don't need it can opt out. We use this internally for automated testing of U-Boot on hardware (and I'm setting up the same thing locally).

I don't deny that it's useful. And it may even ork fine in your specific case.

But the approach is wrong. This code has never been meant to run before relocation.

I object against opening this pandora box.

If you have so ample resources to run such code, then load a minimal configuration of U-Boot.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
What the gods would destroy they first submit to  an  IEEE  standards
committee.
#7 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Quoted 15 lines · Wolfgang Denk

Dear Tom Rini,

Quoted 8 lines · In message <CA+M6bXmKum1B39RVcJ+jgDRmFCFr5sToZYDUVXnM4NfUZ-XQaQ@mail.gmail.com>…
Quoted 4 lines

What originally has been designed to be minimal code now start to pull in all kinds of other crap, that has never been designed to run before relocation.

Boards that don't need it can opt out. ?We use this internally for automated testing of U-Boot on hardware (and I'm setting up the same thing locally).

I don't deny that it's useful. ?And it may even ork fine in your specific case.

Quoted 7 lines

But the approach is wrong. This code has never been meant to run before relocation.

I object against opening this pandora box.

If you have so ample resources to run such code, then load a minimal configuration of U-Boot.

Is this a change of heart then?
http://comments.gmane.org/gmane.comp.boot-loaders.u-boot/109170

Signature · 1 line
Tom
#8 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Dear Tom Rini,

Quoted 7 lines · In message <CA+M6bXnb5k6gA8kbqr0BQ+JLMVFXpzCT+g+dEXfJx307fYn=ew@mail.gmail.com>…
Quoted 5 lines

I object against opening this pandora box.

If you have so ample resources to run such code, then load a minimal configuration of U-Boot.

Is this a change of heart then?

No - I never was happy about pulling arbitrary code into SPL.

Quoted 1 line

http://comments.gmane.org/gmane.comp.boot-loaders.u-boot/109170

I don't see how this is related?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I like your game but we have to change the rules."
#9 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Quoted 9 lines · Wolfgang Denk

Dear Tom Rini,

Quoted 6 lines · In message <CA+M6bXnb5k6gA8kbqr0BQ+JLMVFXpzCT+g+dEXfJx307fYn=ew@mail.gmail.com>…
Quoted 5 lines

I object against opening this pandora box.

If you have so ample resources to run such code, then load a minimal configuration of U-Boot.

Quoted 7 lines
Quoted 1 line

Is this a change of heart then?

No - I never was happy about pulling arbitrary code into SPL.

Quoted 1 line

http://comments.gmane.org/gmane.comp.boot-loaders.u-boot/109170

I don't see how this is related?

If I follow you right, to my question of "How would a user make use of 'ROM loads next loader via USB' program?" your answer is "Have it load a normal U-Boot that's minimally configured". That link is TI saying "we have split things up such that ROM loads U-Boot-Min (a minimally configured U-Boot) which can then load a full U-Boot". You NAK'd the idea then. Have you changed your mind? If so, where are we going to draw the demarcation between "OK for SPL" and "Must use a full U-Boot" ?

Signature · 1 line
Tom
#10 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

In reply to Wolfgang Denk
Quoted 10 lines · Wolfgang Denk

Dear Tom Rini,

Quoted 6 lines · In message <[email protected]> you wrote:

From: Matt Porter <[email protected]>

Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port.

Quoted 4 lines

Does it really make sense to add all kind of bloat to the SPL?

What originally has been designed to be minimal code now start to pull in all kinds of other crap,

What's the alternative -- another name and separate makefile infrastructure for non-minimal initial loaders?

It's important that SPL be *able* to produce very small images when needed, but its purpose has grown beyond that.

Quoted 1 line

that has never been designed to run before relocation.

At least some SPLs do relocation.

-Scott

#11 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Quoted 13 lines · Scott Wood
Quoted 12 lines · Wolfgang Denk

Dear Tom Rini,

Quoted 6 lines · In message <[email protected]> you wrote:

From: Matt Porter <[email protected]>

Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port.

Does it really make sense to add all kind of bloat to the SPL?

Quoted 8 lines
Quoted 2 lines

What originally has been designed to be minimal code now start to pull in all kinds of other crap,

What's the alternative -- another name and separate makefile infrastructure for non-minimal initial loaders?

It's important that SPL be *able* to produce very small images when needed, but its purpose has grown beyond that.

I talked with Wolfgang a little on IRC on this, and we didn't reach a conclusion nor come up with an alternative, but I guess the problem is we need to figure something out, now. We've hit a roadblock on "allow UART loading" and regret over keeping MMC+VFAT working. How bad are things going to get when patches pop up for USB (AM33xx ROM allows for RNDIS USB, iirc) ?

Maybe we need to separate out the systems which are very resource constrained from the ones that aren't, share code where we can and make that code obviously marked as such.

Quoted 3 lines
Quoted 1 line

that has never been designed to run before relocation.

At least some SPLs do relocation.

Or don't need to exactly.

Signature · 1 line
Tom
#12 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Dear Tom Rini,

Quoted 4 lines · In message <CA+M6bXkXA+356AFLGDS55o=7bZuuQCcPCXAVEjo9AWDENn3wfQ@mail.gmail.com>…

Maybe we need to separate out the systems which are very resource constrained from the ones that aren't, share code where we can and make that code obviously marked as such.

I think it's the other way round. You ned to find out which code is safe to call from a restricted environment, and track down the linker dependencies to make sure you don't pull something in that breaks. Which means you need to review all code and mark it's requirements.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Faith may be defined briefly as an illogical belief in the  occurence
of the improbable.                                    - H. L. Mencken
#13 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

Quoted 4 lines · Wolfgang Denk

Dear Tom Rini,

Quoted 1 line · In message <CA+M6bXkXA+356AFLGDS55o=7bZuuQCcPCXAVEjo9AWDENn3wfQ@mail.gmail.com>…
Quoted 8 lines
Quoted 3 lines

Maybe we need to separate out the systems which are very resource constrained from the ones that aren't, share code where we can and make that code obviously marked as such.

I think it's the other way round. You ned to find out which code is safe to call from a restricted environment, and track down the linker dependencies to make sure you don't pull something in that breaks. Which means you need to review all code and mark it's requirements.

So are you then open to playing more linker games, at least for the boot modes where this is rather feasible? (.data.splsafe / .text.splsafe and head.o)

Signature · 1 line
Tom
#14 lore raw

PATCH 1/2 SPL: Add YMODEM over UART load support

In reply to Scott Wood

Dear Scott Wood,

Quoted 3 lines · In message <[email protected]> you wrote:

What's the alternative -- another name and separate makefile infrastructure for non-minimal initial loaders?

No, configura and use a small U-Boot image where the normal execution environment can be guaranteed.

Quoted 2 lines

It's important that SPL be *able* to produce very small images when needed, but its purpose has grown beyond that.

But it's restrictions have not.

You know how things work - people take exsiting code examples from one system and expect them to work on another - and they don't.

The SPL code that works fine today breaks tomorrow because someone changes some part of code in an apparently unrelated area of the code. He could not know his changes would cause trouble because this code was not meant to run in restricted environments. Etc. etc.

We once had a very strict rule for which code was allowed before relocation (or you may call it in "regular U-Boot enviropnment"), and which was not. We are starting to obliterate these boundaries. This is dangerous, and once you start, impossible to control.

It was a mistake of mine to allow the use of malloc() in this environment. I am not willing to let this grow out of control.

If such fancy features are needed in the SPL, then new methods must be developed that give the user a clear indication if what he is doing is actually legal and will result in working code. I don't have a solution for this, but I am convinced that this approach is wrong, and should be stopped rather now than later.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Do you suppose the reason the ends of the `Intel Inside'  logo  don't
match up is that it was drawn on a Pentium?