[U-Boot] Reading data from SPI flash before relocation - what is the best way to do this?

Hello,
I want to chose the best aproach to achive something like this: There is a u-boot without SPL and it is copied by bootrom to SDRAM. In first phase (while running *_f functions) I need to read some configuration data from SPI NOR, and it must be done before DDR config. I have SPI NOR with enabled MTD support on SPI. Problem is that MTD uses bss wich is not avalaible yet. My solutions: * Change linker script to divide bss and rel.dyn sections and clean bss by myself. Disadventage is that it will enlarge my binary, but it migh be acceptable. * Write code that do not use SPI/MTD frameworks to read configuration data (data will be on raw so MTD is not needed). For sure - at least at the moment - I wan't to avoid using SPL and config compiled into binary. Maybe there is another way that I can achive that?
Regards, Marcin

On 22 October 2015 at 17:05, Krzeminski, Marcin (Nokia - PL/Wroclaw) marcin.krzeminski@nokia.com wrote:
Hello,
I want to chose the best aproach to achive something like this: There is a u-boot without SPL and it is copied by bootrom to SDRAM. In first phase (while running *_f functions) I need to read some configuration data from SPI NOR, and it must be done before DDR config.
Why can't you use SPL? any specific reason?
Just to be clear are going write the data from spi-nor to SRAM because *_f doesn't have DDR access.
I have SPI NOR with enabled MTD support on SPI. Problem is that MTD uses bss wich is not avalaible yet. My solutions:
Change linker script to divide bss and rel.dyn sections and clean bss by myself. Disadventage is that it will enlarge my binary, but it migh be acceptable.
Write code that do not use SPI/MTD frameworks to read configuration data (data will be on raw so MTD is not needed).
For sure - at least at the moment - I wan't to avoid using SPL and config compiled into binary. Maybe there is another way that I can achive that?

-----Original Message----- From: EXT Jagan Teki [mailto:jteki@openedev.com] Sent: Thursday, October 22, 2015 2:55 PM To: Krzeminski, Marcin (Nokia - PL/Wroclaw) marcin.krzeminski@nokia.com Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] Reading data from SPI flash before relocation - what is the best way to do this?
On 22 October 2015 at 17:05, Krzeminski, Marcin (Nokia - PL/Wroclaw) marcin.krzeminski@nokia.com wrote:
Hello,
I want to chose the best aproach to achive something like this: There is a u-boot without SPL and it is copied by bootrom to SDRAM. In first phase (while running *_f functions) I need to read some
configuration data from SPI NOR, and it must be done before DDR config.
Why can't you use SPL? any specific reason?
Since we are already in small SDRAM, so assumption was tha SPL is not needed - which was apparently wrong. Strong argument is that dividing u-boot to u-boot and SPL will consume more flash space, complicate flash layout and already complicated boot process.
Just to be clear are going write the data from spi-nor to SRAM because *_f doesn't have DDR access.
Yes.
I have SPI NOR with enabled MTD support on SPI. Problem is that MTD
uses bss wich is not avalaible yet.
My solutions:
Change linker script to divide bss and rel.dyn sections and clean bss by
myself. Disadventage is that it will enlarge my binary, but it migh be acceptable.
Write code that do not use SPI/MTD frameworks to read configuration
data (data will be on raw so MTD is not needed).
For sure - at least at the moment - I wan't to avoid using SPL and config
compiled into binary.
Maybe there is another way that I can achive that?
-- Jagan | openedev.
Regards, Marcin

Dear Marcin,
In message CA0E6F9BA6AED7458C23277BD87075E50F731841@DEMUMBX014.nsn-intra.net you wrote:
I want to chose the best aproach to achive something like this: There is a u-boot without SPL and it is copied by bootrom to SDRAM.
OK, the question why you don't use SPL has already been asked.
In first phase (while running *_f functions) I need to read some configuration data from SPI NOR, and it must be done before DDR config.
Why do you need to read it separately? Can you not "attach" it to the U-Boot image, so the boot ROM will read that combined image (U-Boot plus your config data) ?
Best regards,
Wolfgang Denk

-----Original Message----- From: EXT Wolfgang Denk [mailto:wd@denx.de] Sent: Thursday, October 22, 2015 7:16 PM To: Krzeminski, Marcin (Nokia - PL/Wroclaw) marcin.krzeminski@nokia.com Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] Reading data from SPI flash before relocation - what is the best way to do this?
Dear Marcin,
In message <CA0E6F9BA6AED7458C23277BD87075E50F731841@DEMUMBX014.nsn- intra.net> you wrote:
I want to chose the best aproach to achive something like this: There is a u-boot without SPL and it is copied by bootrom to SDRAM.
OK, the question why you don't use SPL has already been asked.
In first phase (while running *_f functions) I need to read some
configuration data from SPI NOR, and it must be done before DDR config.
Why do you need to read it separately? Can you not "attach" it to the U-Boot image, so the boot ROM will read that combined image (U-Boot plus your config data) ?
Because many configuration are expected, so avoiding many u-boot binaries is the target.
Generally it seems that I want to do something that is against u-boot design, so my question should be, how to do it harmless?
I changed linker script, cleared bss and it seem that this is working fine, so probably I'll try this way.
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Until you walk a mile in another man's moccasins, you can't imagine the smell.
Best regards, Marcin KrzemiĆski
participants (3)
-
Jagan Teki
-
Krzeminski, Marcin (Nokia - PL/Wroclaw)
-
Wolfgang Denk