From: Stefan Date: Wed, 12 Feb 2020 14:46:26 +0100 Subject: [PATCH v3 00/20] Refactor the architecture parts of mt7628 In-Reply-To: References: <1579594674-6665-1-git-send-email-weijie.gao@mediatek.com> <85741485-0d75-dd5c-78a0-34c1eda6c8c4@mclink.it> <5d502f6b-fa16-5d95-3842-2033493b7fd9@mclink.it> <92731912-74f9-e635-5fea-8c9455fcf002@mclink.it> Message-ID: <302ab4e4-cc85-0fc2-3cb6-58adf70d7ff3@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 Hi Daniel, On 12.02.20 13:48, Daniel Schwierzeck wrote: >>> Daniel, perhaps a dumb question, but is the MIPS U-Boot code position >>> independant? > > from your tests I can only conclude that RAM loading doesn't work at > all. If you see it > "working" than you simply junp to the old copy which the SPL created. > A MIPS U-Boot > is always built with position-dependant code. To make the U-Boot > binary relocatable, > we use the tools/mips-relocs.c which was ported from Linux. During > linking we let gcc > emit relocation entries which are post-processed by the mips-relocs > tool. The output > is then inserted into u-boot.bin in section ".data.reloc". Those reloc > entries are then > used by the MIPS relocation code to patch all symbols with the > relative offset to the > new text address. > > If you build for example the Gardena Smart Gateway and disassemble the u-boot > binary (which becomes the SPL payload), the very first instruction is this: > > 80200000 <_start>: > #endif > .endm > > ENTRY(_start) > /* U-Boot entry point */ > b reset > 80200000: 1000013f b 80200500 > mtc0 zero, CP0_COUNT # clear cp0 count for most accurate boot timing > 80200004: 40804800 mtc0 zero,c0_count > > So if you load u-boot.bin to a different address than 0x80200000 and jump to it, > the first instruction is a jump back to address 0x80200500. If the old SPL copy > of u-boot.bin is still there, you'll see a "working" RAM boot. Thanks for this analysis. This is exactly what happened in my test this morning. > Actually Mauro already did the right thing with erasing the load area > at 0x80200000 > before downloading a new binary. > > A stable approach to a RAM boot binary (which I use in my out-of-tree boards) > would be to use a KSEG1 text address e.g. 0xa0200000 and explicitely switch > the CPU to non-caching mode (this is normally skipped with > CONFIG_SKIP_LOWLEVEL_INIT in the SPL payload). This approach always worked > for me for booting via UART or EJTAG without getting messed up by > cache effects. > > So either we officially drop RAM boot support for mtmips platform (respectively > don't use the u-boot.bin intended for SPL payload as RAM boot binary) > or we keep the > special RAM boot configs. I assume that you are also okay with the cache flush approach? I'll send v2 of this patch pretty soon if nobody objects. Thanks, Stefan