1
0
Fork 0
forked from len0rd/rockbox

Self-extracting loader: Cleaner method for inclusion of the UCL-compressed image. The input image is now checked for correctness and converted to C source. The Makefile still needs fixing...

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8109 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-11-30 00:05:40 +00:00
parent 8b022749a7
commit 4c385148ac
4 changed files with 129 additions and 17 deletions

View file

@ -18,13 +18,14 @@ OBJDIR := .
# FIXME: get proper value from build system
MEMORYSIZE = 2
LDS := link.lds
LINKFILE = $(OBJDIR)/linkage.lds
OBJS := $(OBJDIR)/decompressor.o $(OBJDIR)/rockboxucl.o $(OBJDIR)/startup.o
OBJS := $(OBJDIR)/decompressor.o $(OBJDIR)/uclimage.o $(OBJDIR)/startup.o
CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns
all: $(OBJDIR)/compressed.bin
$(OBJDIR)/compressed.bin : $(OBJDIR)/compressed.elf
@echo "OBJCOPY "`basename $@`
@$(OC) -O binary $< $@
@ -37,6 +38,12 @@ $(LINKFILE): $(LDS)
@echo "Build LDS file"
@cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
$(OBJDIR)/rockboxucl.o: $(OBJDIR)/rockbox.ucl
@echo "OBJCOPY rockbox.ucl"
@$(OC) -I binary -O elf32-sh -B sh --rename-section .data=.image,alloc,load,data,contents $< $@
$(OBJDIR)/decompressor.o : $(OBJDIR)/uclimage.h
$(OBJDIR)/uclimage.c : $(OBJDIR)/rockbox.ucl $(TOOLSDIR)/ucl2src.pl
@echo "UCL2SRC"
@perl -s $(TOOLSDIR)/ucl2src.pl -p=uclimage $< $@
$(OBJDIR)/uclimage.h : $(OBJDIR)/rockbox.ucl $(TOOLSDIR)/ucl2src.pl
@echo "UCL2SRC"
@perl -s $(TOOLSDIR)/ucl2src.pl -p=uclimage $< $@

View file

@ -21,13 +21,13 @@
*
****************************************************************************/
#include "uclimage.h"
#define ICODE_ATTR __attribute__ ((section (".icode")))
#define UCL_HEADER 26 /* size of the header generated by uclpack */
/* Symbols defined in the linker script */
extern char iramcopy[], iramstart[], iramend[];
extern char stackend[];
extern char imgstart[], imgend[];
extern char loadaddress[], dramend[];
/* Prototypes */
@ -113,20 +113,19 @@ int ucl_nrv2e_decompress_8(const unsigned char *src, unsigned char *dst,
return ilen;
}
#define ALIGNED_IMG_SIZE ((sizeof(image) + 3) & ~3)
/* This will never return */
void main(void)
{
unsigned long dst_len; /* dummy */
unsigned long img_len = (unsigned long)(imgend - imgstart);
unsigned long *src = (unsigned long *)imgstart;
unsigned long *dst = (unsigned long *)(dramend - img_len);
unsigned long *src = (unsigned long *)image;
unsigned long *dst = (unsigned long *)(dramend - ALIGNED_IMG_SIZE);
do
*dst++ = *src++;
while (dst < (unsigned long *)dramend);
ucl_nrv2e_decompress_8(dramend - img_len + UCL_HEADER,
loadaddress, &dst_len);
ucl_nrv2e_decompress_8(dramend - ALIGNED_IMG_SIZE, loadaddress, &dst_len);
asm(
"mov.l @%0+,r0 \n"

View file

@ -40,15 +40,11 @@ SECTIONS
{
*(.data)
. = ALIGN(0x4);
_imgstart = .;
*(.image)
. = ALIGN(0x4);
_imgend = .;
_iramcopy = .;
} > DRAM
.iram IRAMORIG : AT ( _iramcopy )
{
{
_iramstart = .;
*(.icode)
*(.idata)