Skip to contentSkip to conversation

SPARC: added U-Boot build target: uImage

PATCH Superseded Daniel Hellstrom 2 participants 5 messages Jan 5, 2011 – Jan 6, 2011 SPARC + UltraSPARC (sparc/sparc64)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SPARC: added U-Boot build target: uImage

This is only for LEON as u-boot for SPARC only supports LEON.

---
 arch/sparc/Makefile      |    3 ++-
 arch/sparc/boot/Makefile |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)
arch/sparc/Makefile +2 -1
index 113225b..012d289 100644
@@ -88,7 +88,7 @@ boot := arch/sparc/boot
 # Default target
 all: zImage
 
-image zImage tftpboot.img vmlinux.aout: vmlinux
+image zImage uImage tftpboot.img vmlinux.aout: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
 archclean:
@@ -102,6 +102,7 @@ ifeq ($(ARCH),sparc)
 define archhelp
   echo  '* image        - kernel image ($(boot)/image)'
   echo  '* zImage       - stripped kernel image ($(boot)/zImage)'
+  echo  '  uImage       - U-Boot SPARC32/LEON Image'
   echo  '  tftpboot.img - image prepared for tftp'
 endef
 else
arch/sparc/boot/Makefile +36 -0
index 97e3feb..9574958 100644
@@ -5,6 +5,7 @@
 
 ROOT_IMG	:= /usr/src/root.img
 ELFTOAOUT	:= elftoaout
+MKIMAGE 	:= $(srctree)/scripts/mkuboot.sh
 
 hostprogs-y	:= piggyback_32 piggyback_64 btfixupprep
 targets		:= tftpboot.img btfix.o btfix.S image zImage vmlinux.aout
@@ -90,5 +91,40 @@ $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_64 System.map $(ROOT_IMG) FOR
 $(obj)/vmlinux.aout: vmlinux FORCE
 	$(call if_changed,elftoaout)
 	@echo '  kernel: $@ is ready'
+else
+
+# The following lines make a readable image for U-Boot.
+#  uImage   - Binary file read by U-boot
+#  uImage.o - object file of uImage for loading with a
+#             flash programmer understanding ELF.
+
+OBJCOPYFLAGS_image.bin := -S -O binary -R .note -R .comment
+$(obj)/image.bin: $(obj)/image FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/image.gz: $(obj)/image.bin
+	$(call if_changed,gzip)
+
+# Start of Main memory which this Linux kernel will be loaded to.
+ifndef UIMAGE_LOADADDR
+UIMAGE_LOADADDR=0x40004000
 endif
 
+# The first sector after the U-Boot image (512k). Override this accoring to
+# your u-boot binary size and FLASH block size.
+ifndef UIMAGE_FLASHADDR
+UIMAGE_FLASHADDR=0x00080000
+endif
+
+quiet_cmd_uimage = UIMAGE  $@
+      cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux -T kernel \
+               -C gzip -a $(UIMAGE_LOADADDR) -e 0xf0004000 -n 'Linux-$(KERNELRELEASE)' \
+               -d $< $@
+
+targets += uImage
+$(obj)/uImage: $(obj)/image.gz
+	$(call if_changed,uimage)
+	sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r -b binary arch/sparc/boot/uImage -o arch/sparc/boot/uImage.o
+	@echo '  Image $@ is ready'
+
+endif
Signature · 1 line
1.5.4
#1 lore raw

Hi Daniel.

Quoted 54 lines · Daniel Hellstrom

This is only for LEON as u-boot for SPARC only supports LEON.

---
 arch/sparc/Makefile      |    3 ++-
 arch/sparc/boot/Makefile |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)
arch/sparc/Makefile +2 -1
index 113225b..012d289 100644
@@ -88,7 +88,7 @@ boot := arch/sparc/boot
 # Default target
 all: zImage
 
-image zImage tftpboot.img vmlinux.aout: vmlinux
+image zImage uImage tftpboot.img vmlinux.aout: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
 archclean:
@@ -102,6 +102,7 @@ ifeq ($(ARCH),sparc)
 define archhelp
   echo  '* image        - kernel image ($(boot)/image)'
   echo  '* zImage       - stripped kernel image ($(boot)/zImage)'
+  echo  '  uImage       - U-Boot SPARC32/LEON Image'
   echo  '  tftpboot.img - image prepared for tftp'
 endef
 else
arch/sparc/boot/Makefile +10 -0
index 97e3feb..9574958 100644
@@ -5,6 +5,7 @@
 
 ROOT_IMG	:= /usr/src/root.img
 ELFTOAOUT	:= elftoaout
+MKIMAGE 	:= $(srctree)/scripts/mkuboot.sh
 
 hostprogs-y	:= piggyback_32 piggyback_64 btfixupprep
 targets		:= tftpboot.img btfix.o btfix.S image zImage vmlinux.aout
@@ -90,5 +91,40 @@ $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_64 System.map $(ROOT_IMG) FOR
 $(obj)/vmlinux.aout: vmlinux FORCE
 	$(call if_changed,elftoaout)
 	@echo '  kernel: $@ is ready'
+else
+
+# The following lines make a readable image for U-Boot.
+#  uImage   - Binary file read by U-boot
+#  uImage.o - object file of uImage for loading with a
+#             flash programmer understanding ELF.
+
+OBJCOPYFLAGS_image.bin := -S -O binary -R .note -R .comment
+$(obj)/image.bin: $(obj)/image FORCE

arch/sparc/boot/Makefile $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_64 System.map $(ROOT_IMG) FOR · line 112

Quoted 10 lines
arch/sparc/boot/Makefile +8 -0
+	$(call if_changed,objcopy)
+
+$(obj)/image.gz: $(obj)/image.bin
+	$(call if_changed,gzip)
+
+# Start of Main memory which this Linux kernel will be loaded to.
+ifndef UIMAGE_LOADADDR
+UIMAGE_LOADADDR=0x40004000
 endif
 

Rather than hardcoding such addresses in the Makefile could we come up with something so we get board support included in the KConfig files?

I for once would love to be able to select
"GR-LEON4-ITX" in Kconfig and then everything is
set correct up concerning LOADADDR for uimage.

Same goes for the start address which is hardcoded to 0xf0004000.

I looked briefly at the other archs but did not find a good one to copy this from.

Quoted 6 lines
arch/sparc/boot/Makefile +6 -0
+# The first sector after the U-Boot image (512k). Override this accoring to
+# your u-boot binary size and FLASH block size.
+ifndef UIMAGE_FLASHADDR
+UIMAGE_FLASHADDR=0x00080000
+endif
+

arch/sparc/boot/Makefile $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_64 System.map $(ROOT_IMG) FOR · line 128

Quoted 10 lines
arch/sparc/boot/Makefile +10 -0
+quiet_cmd_uimage = UIMAGE  $@
+      cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux -T kernel \
+               -C gzip -a $(UIMAGE_LOADADDR) -e 0xf0004000 -n 'Linux-$(KERNELRELEASE)' \
+               -d $< $@
+
+targets += uImage
+$(obj)/uImage: $(obj)/image.gz
+	$(call if_changed,uimage)
+	sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r -b binary arch/sparc/boot/uImage -o arch/sparc/boot/uImage.o
+	@echo '  Image $@ is ready'

What is the purpose of uImage.o?
At least sh does not have it - but thay have a lot of other U-boot targets. And can we fix is so we get a nice display when the command is executed?

Sam

#2 lore raw
In reply to Daniel Hellstrom

Hi Sam,

On Wed, 5 Jan 2011 20:19:15 0100, Sam Ravnborg wrote:
Hi Daniel.

Quoted 37 lines · Daniel Hellstrom
Quoted 35 lines

This is only for LEON as u-boot for SPARC only supports LEON.

---
 arch/sparc/Makefile      |    3   -
 arch/sparc/boot/Makefile |   36
 2 files changed, 38 insertions( ), 1 deletions(-)
arch/sparc/Makefile +0 -1
index 113225b..012d289 100644
--- a/arch/sparc/Makefile
    b/arch/sparc/Makefile

@@ -88,7 88,7 @@ boot := arch/sparc/boot
# Default target
all: zImage

-image zImage tftpboot.img vmlinux.aout: vmlinux
image zImage uImage tftpboot.img vmlinux.aout: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@

archclean:
@@ -102,6 102,7 @@ ifeq ($(ARCH),sparc)
define archhelp

   echo  '* image        - kernel image ($(boot)/image)'
   echo  '* zImage       - stripped kernel image ($(boot)/zImage)'
   echo  '  uImage       - U-Boot SPARC32/LEON Image'
   echo  '  tftpboot.img - image prepared for tftp'

endef
else

arch/sparc/boot/Makefile +0 -1
index 97e3feb..9574958 100644
--- a/arch/sparc/boot/Makefile
    b/arch/sparc/boot/Makefile

@@ -5,6 5,7 @@

Quoted 7 lines
Quoted 7 lines

ROOT_IMG := /usr/src/root.img
ELFTOAOUT := elftoaout
MKIMAGE := $(srctree)/scripts/mkuboot.sh

hostprogs-y := piggyback_32 piggyback_64 btfixupprep targets := tftpboot.img btfix.o btfix.S image zImage vmlinux.aout
@@ -90,5 91,40 @@ $(obj)/tftpboot.img: $(obj)/image

$(obj)/piggyback_64 System.map $(ROOT_IMG) FOR

Quoted 23 lines
Quoted 14 lines

$(obj)/vmlinux.aout: vmlinux FORCE
$(call if_changed,elftoaout)
@echo ' kernel: $@ is ready'
else

# The following lines make a readable image for U-Boot.
# uImage - Binary file read by U-boot
# uImage.o - object file of uImage for loading with a
# flash programmer understanding ELF.

OBJCOPYFLAGS_image.bin := -S -O binary -R .note -R .comment $(obj)/image.bin: $(obj)/image FORCE
$(call if_changed,objcopy)

Quoted 8 lines

$(obj)/image.gz: $(obj)/image.bin
$(call if_changed,gzip)

# Start of Main memory which this Linux kernel will be loaded to. ifndef UIMAGE_LOADADDR
UIMAGE_LOADADDR=0x40004000
endif

Quoted 3 lines

Rather than hardcoding such addresses in the Makefile could we come up with something so we get board support included in the KConfig files?


Of course, however is that really good, I mean we don't want to
rebuild the kernel just to change the load location. One kernel may end up at different addresses at different boards...

It is not really hardcoded, it is just the default address, one can
override the defualt address by adding a define at the make line, for example:

  $ make ARCH=sparc CROSS_COMPILE=sparc-linux- 
UIMAGE_LOADADDR=0x00004000 uImage
   
Quoted 4 lines

I for once would love to be able to select
"GR-LEON4-ITX" in Kconfig and then everything is
set correct up concerning LOADADDR for uimage.


There are very many different boards to support, that is a lot of job
maintaining, I'm not sure we want to go there. Note that the LEON is a SoC and that there a lot of different chips, and a lot of different boards... Why the LEON3 port works without a BSP between the different chips/boards are thanks to Plug&Play at the processor local bus... The standard location of all LEON3 is basically 0x40004000 or 0x60004000 (if two memory interfaces are supported), I can only think of one chip that has this different.

Quoted 8 lines

Same goes for the start address which is hardcoded to 0xf0004000.

I looked briefly at the other archs but did not find a good one to copy this from.

Quoted 1 line

# The first sector after the U-Boot image (512k). Override this

accoring to

Quoted 7 lines
Quoted 7 lines
 # your u-boot binary size and FLASH block size. 
 ifndef UIMAGE_FLASHADDR
 UIMAGE_FLASHADDR=0x00080000
 endif

quiet_cmd_uimage = UIMAGE $@

       cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux 

-T kernel \

Quoted 1 line
Quoted 1 line
                -C gzip -a $(UIMAGE_LOADADDR) -e 0xf0004000 -n 

'Linux-$(KERNELRELEASE)' \

Quoted 6 lines
Quoted 6 lines
                -d $< $@

targets = uImage
$(obj)/uImage: $(obj)/image.gz
$(call if_changed,uimage)
sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r -b binary

arch/sparc/boot/uImage -o arch/sparc/boot/uImage.o

Quoted 3 lines
Quoted 1 line

@echo ' Image $@ is ready'

What is the purpose of uImage.o?

The uImage is readable by u-boot and can be loaded into memory by
U-BOOT, however sometimes is easier to load the uImage image directly into RAM/FLASH using a tool such as GRMON/TSIM/GRSIM. So the uImage.o is an ELF image ready to be loaded into memory using a debugger of some sort, just for convenience when networking isn't available for u-boot or when a system is first time programmed before shipping...

Quoted 2 lines

At least sh does not have it - but thay have a lot of other U-boot targets. And can we fix is so we get a nice display when the command is executed?


what do you what to be printed? is another echo enough?

Best Regards,
Daniel

#3 lore raw
In reply to Daniel Hellstrom
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

$(obj)/image.gz: $(obj)/image.bin
$(call if_changed,gzip)

# Start of Main memory which this Linux kernel will be loaded to. ifndef UIMAGE_LOADADDR
UIMAGE_LOADADDR=0x40004000
endif

Quoted 7 lines
Quoted 3 lines

Rather than hardcoding such addresses in the Makefile could we come up with something so we get board support included in the KConfig files?


Of course, however is that really good, I mean we don't want to
rebuild the kernel just to change the load location. One kernel may end up at different addresses at different boards...

kbuild is smart enough to only rebuild what needs to be rebuild when we change the configuration.

So if we have:
config SPARC_UIMAGE_LAODADDR
depends on SPARC_LEON
int "Start of Main memory which this Linux kernel will be loaded to"

Then if you type "make" then only uimage is
called - and nothing else is rebuilt.

Quoted 6 lines


It is not really hardcoded, it is just the default address, one can
override the defualt address by adding a define at the make line, for example:

 $ make ARCH=sparc CROSS_COMPILE=sparc-linux-
UIMAGE_LOADADDR=0x00004000 uImage

This would still be possible - the names just have a CONFIG_ prefix.

Quoted 4 lines
Quoted 4 lines

I for once would love to be able to select
"GR-LEON4-ITX" in Kconfig and then everything is
set correct up concerning LOADADDR for uimage.

Quoted 9 lines


There are very many different boards to support, that is a lot of job
maintaining, I'm not sure we want to go there. Note that the LEON is a SoC and that there a lot of different chips, and a lot of different boards... Why the LEON3 port works without a BSP between the different chips/boards are thanks to Plug&Play at the processor local bus... The standard location of all LEON3 is basically 0x40004000 or 0x60004000 (if two memory interfaces are supported), I can only think of one chip that has this different.

But then lets go for a simpler variant where you at least cover these two typical setups.
Then the board can document that they need "LEON BSP Type 1" og "LEON BSP Type 2" in the kernel.

(Random names - we need better names).

Quoted 22 lines
Quoted 2 lines
Quoted 2 lines

quiet_cmd_uimage = UIMAGE $@

       cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux

-T kernel \

Quoted 1 line
Quoted 1 line
                -C gzip -a $(UIMAGE_LOADADDR) -e 0xf0004000 -n

'Linux-$(KERNELRELEASE)' \

Quoted 6 lines
Quoted 6 lines
                -d $< $@

targets = uImage
$(obj)/uImage: $(obj)/image.gz
$(call if_changed,uimage)
sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r -b binary

arch/sparc/boot/uImage -o arch/sparc/boot/uImage.o

Quoted 3 lines
Quoted 1 line

@echo ' Image $@ is ready'

What is the purpose of uImage.o?

The uImage is readable by u-boot and can be loaded into memory by
U-BOOT, however sometimes is easier to load the uImage image directly into RAM/FLASH using a tool such as GRMON/TSIM/GRSIM. So the uImage.o is an ELF image ready to be loaded into memory using a debugger of some sort, just for convenience when networking isn't available for u-boot or when a system is first time programmed before shipping...

Quoted 4 lines
Quoted 2 lines

At least sh does not have it - but thay have a lot of other U-boot targets. And can we fix is so we get a nice display when the command is executed?


what do you what to be printed? is another echo enough?

I have in mind something like this:
quiet_cmd_uimage.o = UIMAGE.O $@

      cmd_uimage.o = sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r -b binary \
                     $@ -o [email protected]

Then you can just do:

	$(call cmd,uimage.o)

    Sam
#4 lore raw
In reply to Daniel Hellstrom
Quoted 20 lines · Sam Ravnborg
Quoted 9 lines
Quoted 9 lines

$(obj)/image.gz: $(obj)/image.bin

Quoted 7 lines
  $(call if_changed,gzip)

# Start of Main memory which this Linux kernel will be loaded to. ifndef UIMAGE_LOADADDR
UIMAGE_LOADADDR=0x40004000
endif

Quoted 7 lines
Quoted 3 lines

Rather than hardcoding such addresses in the Makefile could we come up with something so we get board support included in the KConfig files?


Of course, however is that really good, I mean we don't want to
rebuild the kernel just to change the load location. One kernel may end up at different addresses at different boards...

kbuild is smart enough to only rebuild what needs to be rebuild when we change the configuration.

Quoted 7 lines

So if we have:
config SPARC_UIMAGE_LAODADDR
depends on SPARC_LEON
int "Start of Main memory which this Linux kernel will be loaded to"

Then if you type "make" then only uimage is
called - and nothing else is rebuilt.


Ok, that settles it, I will update this patch with a Kconfig option.

Quoted 25 lines
Quoted 7 lines


It is not really hardcoded, it is just the default address, one can
override the defualt address by adding a define at the make line, for example:

 $ make ARCH=sparc CROSS_COMPILE=sparc-linux-
UIMAGE_LOADADDR=0x00004000 uImage

This would still be possible - the names just have a CONFIG_ prefix.

Quoted 4 lines
Quoted 4 lines

I for once would love to be able to select "GR-LEON4-ITX" in Kconfig and then everything is set correct up concerning LOADADDR for uimage.

Quoted 9 lines


There are very many different boards to support, that is a lot of job
maintaining, I'm not sure we want to go there. Note that the LEON is a SoC and that there a lot of different chips, and a lot of different boards... Why the LEON3 port works without a BSP between the different chips/boards are thanks to Plug&Play at the processor local bus... The standard location of all LEON3 is basically 0x40004000 or 0x60004000 (if two memory interfaces are supported), I can only think of one chip that has this different.

Quoted 6 lines

But then lets go for a simpler variant where you at least cover these two typical setups.
Then the board can document that they need "LEON BSP Type 1" og "LEON BSP Type 2" in the kernel.

(Random names - we need better names).


I think it will do with one hex option per config, since any chip
manufacturer may set any address. I will try to come up with a name for it.

Quoted 15 lines
Quoted 15 lines
Quoted 3 lines
Quoted 3 lines

quiet_cmd_uimage = UIMAGE $@

       cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux

-T kernel \

Quoted 1 line
Quoted 1 line
                -C gzip -a $(UIMAGE_LOADADDR) -e 0xf0004000 -n

'Linux-$(KERNELRELEASE)' \

Quoted 6 lines
Quoted 6 lines
                -d $< $@

targets = uImage
$(obj)/uImage: $(obj)/image.gz
$(call if_changed,uimage)
sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r -b binary

arch/sparc/boot/uImage -o arch/sparc/boot/uImage.o

Quoted 2 lines
Quoted 1 line

@echo ' Image $@ is ready'

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

What is the purpose of uImage.o?

The uImage is readable by u-boot and can be loaded into memory by
U-BOOT, however sometimes is easier to load the uImage image directly into RAM/FLASH using a tool such as GRMON/TSIM/GRSIM. So the uImage.o is an ELF image ready to be loaded into memory using a debugger of some sort, just for convenience when networking isn't available for u-boot or when a system is first time programmed before shipping...

Quoted 1 line

At least sh does not have it - but thay have a lot of other

U-boot targets.

Quoted 1 line
Quoted 1 line
Quoted 1 line

And can we fix is so we get a nice display when the command is

executed?

Quoted 6 lines
Quoted 2 lines


what do you what to be printed? is another echo enough?

I have in mind something like this:
quiet_cmd_uimage.o = UIMAGE.O $@

      cmd_uimage.o = sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r 

-b binary \

Quoted 5 lines
                     $@ -o [email protected]

Then you can just do:

$(call cmd,uimage.o)


Sounds good,

Thanks for your input,
Daniel