From: Gabor Juhos <juhosg@openwrt.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] MIPS: use CONFIG_SYS_TEXT_BASE in relocation calculations
Date: Mon, 11 Nov 2013 21:31:30 +0100 [thread overview]
Message-ID: <52813EA2.70209@openwrt.org> (raw)
In-Reply-To: <CACUy__UfwoM443sSS29Z0PhhXUTKeLMHcp5ppaU+i9g94FYmiQ@mail.gmail.com>
2013.11.11. 20:36 keltez?ssel, Daniel Schwierzeck ?rta:
> 2013/11/11 Gabor Juhos <juhosg@openwrt.org>:
>> The relocation code uses the CONFIG_SYS_MONITOR_BASE
>> constant for calculating the reserved memory size and
>> relocation offset values. Along with these predefined
>> values the code also uses several other constants which
>> are computed by the linker from the CONFIG_SYS_TEXT_BASE
>> value. Due to this, the relocation code works incorreclty
>> if the CONFIG_SYS_TEXT_BASE and CONFIG_SYS_MONITOR_BASE
>> values are different.
>
> to be consistent with all other architectures, we should keep
> CONFIG_SYS_MONITOR_BASE. I think it is neither valid nor intentional
> to use a value different from CONFIG_SYS_TEXT_BASE.
If it is neither valid nor intentional, the CONFIG_SYS_MONITOR_BASE constant
should not exist at all and CONFIG_SYS_TEXT_BASE should be used everywhere
instead IMHO.
Additionally, we have this check in arch/mips/lib/board.c:
> #if CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
> bd->bi_flashoffset = monitor_flash_len; /* reserved area for U-Boot */
> #else
> bd->bi_flashoffset = 0;
> #endif
If it is not allowed to use different values for the two constants,
the condition and the #else branch should be removed.
> Instead we should change include/configs/malta.h:
>
> -#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE
> +#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
>
>
> Comments?
I have tried this already. It is working as well, however with this change the
flash sectors containing the bootloader are not protected correctly:
> malta # flinfo
>
> Bank # 1: CFI conformant flash (32 x 32) Size: 4 MB in 64 Sectors
> Intel Extended command set, Manufacturer ID: 0x00, Device ID: 0x00
> Erase timeout: 16384 ms, write timeout: 3 ms
> Buffer write timeout: 3 ms, buffer size: 2048 bytes
>
> Sector Start Addresses:
> BE000000 BE010000 BE020000 BE030000 BE040000
> BE050000 BE060000 BE070000 BE080000 BE090000
> BE0A0000 BE0B0000 BE0C0000 BE0D0000 BE0E0000
> BE0F0000 BE100000 BE110000 BE120000 BE130000
> BE140000 BE150000 BE160000 BE170000 BE180000
> BE190000 BE1A0000 BE1B0000 BE1C0000 BE1D0000
> BE1E0000 BE1F0000 BE200000 BE210000 BE220000
> BE230000 BE240000 BE250000 BE260000 BE270000
> BE280000 BE290000 BE2A0000 BE2B0000 BE2C0000
> BE2D0000 BE2E0000 BE2F0000 BE300000 BE310000
> BE320000 BE330000 BE340000 BE350000 BE360000
> BE370000 BE380000 BE390000 BE3A0000 BE3B0000
> BE3C0000 BE3D0000 BE3E0000 RO BE3F0000 RO
> malta #
For reference, this is the output of flinfo with my change:
> malta # flinfo
>
> Bank # 1: CFI conformant flash (32 x 32) Size: 4 MB in 64 Sectors
> Intel Extended command set, Manufacturer ID: 0x00, Device ID: 0x00
> Erase timeout: 16384 ms, write timeout: 3 ms
> Buffer write timeout: 3 ms, buffer size: 2048 bytes
>
> Sector Start Addresses:
> BE000000 RO BE010000 RO BE020000 RO BE030000 BE040000
> BE050000 BE060000 BE070000 BE080000 BE090000
> BE0A0000 BE0B0000 BE0C0000 BE0D0000 BE0E0000
> BE0F0000 BE100000 BE110000 BE120000 BE130000
> BE140000 BE150000 BE160000 BE170000 BE180000
> BE190000 BE1A0000 BE1B0000 BE1C0000 BE1D0000
> BE1E0000 BE1F0000 BE200000 BE210000 BE220000
> BE230000 BE240000 BE250000 BE260000 BE270000
> BE280000 BE290000 BE2A0000 BE2B0000 BE2C0000
> BE2D0000 BE2E0000 BE2F0000 BE300000 BE310000
> BE320000 BE330000 BE340000 BE350000 BE360000
> BE370000 BE380000 BE390000 BE3A0000 BE3B0000
> BE3C0000 BE3D0000 BE3E0000 RO BE3F0000 RO
> malta #
Any idea how can we resolve this properly?
-Gabor
next prev parent reply other threads:[~2013-11-11 20:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 19:02 [U-Boot] [PATCH] MIPS: use CONFIG_SYS_TEXT_BASE in relocation calculations Gabor Juhos
2013-11-11 19:15 ` Daniel Schwierzeck
2013-11-11 19:36 ` Daniel Schwierzeck
2013-11-11 20:31 ` Gabor Juhos [this message]
2013-11-11 22:36 ` Daniel Schwierzeck
2013-11-12 14:54 ` Gabor Juhos
2013-11-12 15:40 ` Daniel Schwierzeck
2013-11-12 15:47 ` Gabor Juhos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52813EA2.70209@openwrt.org \
--to=juhosg@openwrt.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox