[U-Boot-Users] Re: Lowering memory footprint -- asking for reviewers!

Wolfgang Denk wd at denx.de
Sat Sep 24 23:52:42 CEST 2005


Dear Ladislav,

in message <20050112133156.GA7451 at orphique> you wrote:
> 
> I ported U-Boot to OMAP5910 based board and before submiting patch I'd
> like to discuss few issues.
> 
> Board has 64M RAM and 32M bit mirror flash, which is quite sufficient to
> run U-Boot under normal circumstancies. During production of prototypes
> I met few boards with bad printed circuit board or bad soldering.
> Therefore I decided to run U-Boot from OMAP's 192kB internal RAM located
> at 2000'0000-2002'ffff with TEXT_BASE set to 2001'2000. That way I have
> 64kB heap and 8kB stack, which I found is sufficient for my needs. Such
> setup helps a lot while debugging hardware problems, despite I know it
> could be done different way, but it would be pity not to use U-Boot's
> power :)
> 
> Because CFG_MALLOC_LEN is 64k-128 something like this is needed to startup
> code:
> 
> Index: cpu/arm925t/start.S
> ===================================================================
> RCS file: /cvsroot/u-boot/u-boot/cpu/arm925t/start.S,v
> retrieving revision 1.8
> diff -u -r1.8 start.S
> --- cpu/arm925t/start.S	9 Jan 2005 17:12:29 -0000	1.8
> +++ cpu/arm925t/start.S	12 Jan 2005 12:45:27 -0000
> @@ -83,6 +83,10 @@
>  
>  _TEXT_BASE:
>  	.word	TEXT_BASE
> +_STACK_OFS:
> +	.word	CFG_MALLOC_LEN + CFG_GBL_DATA_SIZE
> +_BAD_STACK_OFS:
> +	.word	CFG_MALLOC_LEN + CFG_GBL_DATA_SIZE + CONFIG_STACKSIZE + 8
>  
>  .globl _armboot_start
>  _armboot_start:
> @@ -188,8 +192,8 @@
>  	/* Set up the stack						    */
>  stack_setup:
>  	ldr	r0, _TEXT_BASE		/* upper 128 KiB: relocated uboot   */
> -	sub	r0, r0, #CFG_MALLOC_LEN	/* malloc area                      */
> -	sub	r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo                        */
> +	ldr	r1, _STACK_OFS
> +	sub	r0, r0, r1		/* malloc area and bdinfo           */
>  #ifdef CONFIG_USE_IRQ
>  	sub	r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
>  #endif
> @@ -293,8 +297,8 @@
>  	stmia	sp, {r0 - r12}			@ Save user registers (now in svc mode) r0-r12
>  
>  	ldr	r2, _armboot_start
> -	sub	r2, r2, #(CONFIG_STACKSIZE+CFG_MALLOC_LEN)
> -	sub	r2, r2, #(CFG_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
> +	ldr	r13, _BAD_STACK_OFS
> +	sub     r2, r2, r13
>  	ldmia	r2, {r2 - r3}                   @ get values for "aborted" pc and cpsr (into parm regs)
>  	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
>  
> @@ -326,8 +330,8 @@
>  
>  	.macro get_bad_stack
>  	ldr	r13, _armboot_start		@ setup our mode stack
> -	sub	r13, r13, #(CONFIG_STACKSIZE+CFG_MALLOC_LEN)
> -	sub	r13, r13, #(CFG_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
> +	ldr     r2, _BAD_STACK_OFS
> +	sub     r13, r13, r2
>  
>  	str	lr, [r13]			@ save caller lr in position 0 of saved stack
>  	mrs	lr, spsr                        @ get the spsr
>

So far I haven't seen any comments on this list.

Anybody out there to check if this is OK?

At first glance  I  don't  see  much  difference  between  using  the
constants  as  immediate  operands  versus  your version (except that
you're using additional registers). Can you  please  explain  (again)
what the modification is trying to fix?

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Prediction is very difficult, especially of the future.  - Niels Bohr




More information about the U-Boot mailing list