From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Fri, 01 Oct 2010 10:28:38 +0200 Subject: [U-Boot] ARM relocation, probably trivial mistake In-Reply-To: <20101001075131.779CE1539A0@gemini.denx.de> References: <4CA49746.2050301@emk-elektronik.de> <4CA4AEFF.3050101@denx.de> <20100930174308.070ECD2B48C@gemini.denx.de> <4CA570D3.9040406@denx.de> <4CA57468.6090702@free.fr> <4CA57762.3000201@denx.de> <20101001075131.779CE1539A0@gemini.denx.de> Message-ID: <4CA59BB6.7090203@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Wolfgang, Wolfgang Denk wrote: > Dear Heiko Schocher, > > In message <4CA57762.3000201@denx.de> you wrote: >> If u-boot starts in RAM, then it is the task from the preloader >> where it copies u-boot code, and if there is somewhere in IRAM >> enough room for it, this would be an option. Otherwise it is a >> problem if relocation results in overlapping source and destination >> areas ... but you will fast detect this problem, when you see, >> that u-boot no longer works ;-) > > I think we have to be careful here. > > Please keep in mind that the with the new setup the relocation address > is not a constant, not even for systems that come with a fixed memroy > configuration. > > If you enable for example the protected RAM feature, the relocation > address will be shifted down by the amount needed for the reserved > PRAM area - which is variable, as it can be set through an > environment variable. > > So assume you have a system with a preloader, and you optimize your > configuration to load U-Bot to the "final" position close to the end > of the RAM. Not the user defines "setenv pram 128" and reboots. > Now U-Boot will try to relocate itself 128 kB down, which pretty > reliably causes an overlap. Good point ... > Eventually we have to detect such situations and relocate twice then? Hmm.. just an idea: We calculate the relocation address in arch/arm/lib/board.c board_init_f() So, it should be possible to add a check if relocation_address + u-boot_len < TEXT_BASE If this is not the case, we can try to relocate twice ... but this will result in one more copy of u-boot ... ... easier would be, not to use such a setting (relocate address == TEXT_BASE) on a board which uses such features ... bye, Heiko -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany