SPI Flash Rom Header

Talking about OS and emulation core development
Post Reply
macromorgan
Posts: 97
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 37 times
Contact:

SPI Flash Rom Header

Post by macromorgan »

Can someone from Hardkernel tell me if there was a special command or method you used to generate the idbloader for the SPI flash firmware? I notice in the source code it uses one that already exists, and it seems (to me) to be different than the one used for SD booting.

I'm struggling with upstream u-boot and trying to determine if there is something I need to be doing to the TPL/SPL stage to get the BROM to read it from the SPI chip.

Thank you.

macc24
Posts: 30
Joined: Sun Sep 20, 2020 11:31 pm
languages_spoken: english polish
ODROIDs: GoA-BE, GoS
Has thanked: 6 times
Been thanked: 15 times
Contact:

Re: SPI Flash Rom Header

Post by macc24 »

This kinda is a thing, might want to try this.
https://github.com/hardkernel/u-boot/bl ... ing.sh#L16

macromorgan
Posts: 97
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 37 times
Contact:

Re: SPI Flash Rom Header

Post by macromorgan »

Right, my issue is that the idbloader.img that is generated by the make.sh script from the u-boot tree for the OGA doesn't generate the idbloader.img for the SPI flash chip, only the SD card. The idbloader.img for the SPI flash appears to be pre-generated, and I'm curious as to how that's done because it appears to differ substantially from the one generated by the make.sh script.

I can't no matter what I do seem to get upstream TPL/SPL to boot from the SPI flash chip. When I write either an idbloader.img that I generate using the make.sh script, one that I generate following rockchip's own instructions here, or a TPL/SPL image I generate following the same instructions on that page it refuses to boot or spit anything out to the serial console. However, if I dissect the recovery image and flash the relevant bits (about 32KB after the start of the image through at a length of maybe 200KB or so) THAT works, sort of. The only problem is the miniloader as it's configured does a few things I wish I could change, namely it tries to boot off the SD card first and tries to look for a DTB file not using the upstream naming convention.

After further dissection a few other odd things I noticed.
1) doing a dump of strings (using the strings command) on the SPI idbloader.img that I rip from the stock loader, it looks like they might be using the miniloaderall.bin file which doesn't seem to be distributed (openly) by Rockchip as best I can tell.
2) the max TPL size listed in all the source code I can find is 10240, but when I do a dumpimage on what I ripped from the SPI loader I see this: "Init Data Size: 12288 bytes". Every other idbloader.img I see has it as 10240 which is what all the sources tell me is the max.
3) the spi idbloader.img is built entirely with the loaderimage tool (you can pass multiple files to it by using a colon as a seperator), whereas the sd idbloader.img is built using loaderimage tool on the ddr program and then cat-ing the rest of the loader onto it. Don't think it's a substantial change, but it is another difference I noticed.

That all said, can someone shed some light on how the SPI recovery image was created? Since the miniloader is distributed in binary form I can't tell just from looking at it, and it would sure be nice if I could figure out a way to get the upstream TPL/SPL running off the internal SPI flash. Obviously getting the SFC working is also something that needs to be done, but if there is no way to even get the BROM to see the loader what's the point?

User avatar
odroid
Site Admin
Posts: 37286
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1749 times
Been thanked: 1127 times
Contact:

Re: SPI Flash Rom Header

Post by odroid »

We will make a guide how to build a SPI flash image on our wiki pages within a couple of days.
These users thanked the author odroid for the post:
macromorgan (Wed Apr 07, 2021 10:51 pm)

macromorgan
Posts: 97
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 37 times
Contact:

Re: SPI Flash Rom Header

Post by macromorgan »

odroid wrote:
Wed Apr 07, 2021 12:14 pm
We will make a guide how to build a SPI flash image on our wiki pages within a couple of days.
Thank you, I sincerely appreciate it.

For the record though most of the steps are "documented" in reading the make.sh and build_recovery.sh scripts, it's just the generation of the rk3326_header_miniloader_spiboot.img file that's distributed in binary pre-packaged form that I'm curious about. Rockchip distributes the unpackaged binaries, I'm just curious how you go from those to the packaged version.

lsc1117
Posts: 220
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 3 times
Been thanked: 27 times
Contact:

Re: SPI Flash Rom Header

Post by lsc1117 »

@macromorgan,

We have made a guide on how to build an SPI flash image including the SPI ROM structure.
Please refer to our wiki.
https://wiki.odroid.com/odroid_go_advan ... s/spi_boot
These users thanked the author lsc1117 for the post (total 2):
macromorgan (Thu Apr 08, 2021 11:38 pm) • macc24 (Fri Apr 09, 2021 6:50 am)

macromorgan
Posts: 97
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 37 times
Contact:

Re: SPI Flash Rom Header

Post by macromorgan »

Thank you; while I appreciate it I'm still curious how you built the rk3326_header_miniloader_spiboot.img though. It looks like it's some of the loader binaries that rockchip distributes here, however it's how they are packaged that I can't seem to figure out. I was wondering if you could answer that.

The reason I ask is because I'd like to pursue using upstream u-boot off of the SPI flash chip. While I can get upstream u-boot working from SD card I can't get the BROM to see the TPL/SPL, and I'm curious what I'm doing wrong.

The reason why I'm curious about upstream u-boot is 2 fold:

The main reason is because reboot is not working currently on the mainline kernel, and 2 of the 3 potential solutions I'm looking at involve u-boot. The root cause is because the mainline kernel wants to use the PSCI calls to handle system power (off, sleep, reboot) and reboot is not implemented here properly for the Odroid Go Advance. If I modify upstream Arm Trusted Firmware I think I can get that to work though by changing the behavior of the reset function (the RK817 uses the same pin for reset and sleep which is the tricky bit here). A 2nd method which also relies on u-boot can also utilize the WDT to handle system reboot which does work today; however in doing so it doesn't reset the MMC card correctly, meaning I have to tell u-boot to reset the card before it attempts to boot from it. In both of these cases I need U-boot to boot from the TPL/SPL (since Rockchip's miniloader handles the ATF stuff and refuses to boot if an SD card is semi-present as is the case when the WDT reboots the system). The 3rd option which I have the least faith in getting upstreamed is to add a reboot notifier to the RK808 MFD driver; this is how it's done in Rockchip's downstream kernel driver. Upstream some devices that use the RK808 use the device for system power off though, and while it's not currently implemented for the RK817 it would be trivial to do so; I'd just have to also add a reboot notifier too.

The other reason I'm curious about U-boot is because I want to try setting up a simple framebuffer so I can have a seamless handoff of the framebuffer from u-boot to Linux for upstream linux. Not sure if I can but it would be cool if I could.

macromorgan
Posts: 97
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 37 times
Contact:

Re: SPI Flash Rom Header

Post by macromorgan »

lsc1117 wrote:
Thu Apr 08, 2021 7:01 pm
@macromorgan,

We have made a guide on how to build an SPI flash image including the SPI ROM structure.
Please refer to our wiki.
https://wiki.odroid.com/odroid_go_advan ... s/spi_boot
Actually, it turns out in a weird way you solved my problem so thank you very much!

While the TPL/SPL should be written to sector 64 on the SD card, it turns out the bootrom is looking for it at sector 128 instead for some reason. In the SPI flash layout you posted on the wiki page the miniloader said it started in sector 128 which I thought was a typo at first, but when I tried it then it worked!

Booting from the SPI flash chip with no SD card present:

Code: Select all

U-Boot TPL board init
DDR3, 333MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out

U-Boot SPL 2021.04 (Apr 08 2021 - 09:59:01 -0500)
Trying to boot from MMC1
Card did not respond to voltage select! : -110
spl: mmc init failed with error: -95
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
Now to see if I can get the SFC to work in U-boot!

User avatar
odroid
Site Admin
Posts: 37286
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1749 times
Been thanked: 1127 times
Contact:

Re: SPI Flash Rom Header

Post by odroid »

'rk3326_header_miniloader_spiboot' file was generated by Rockchip. We've used it as it was.

macromorgan
Posts: 97
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 37 times
Contact:

Re: SPI Flash Rom Header

Post by macromorgan »

odroid wrote:
Fri Apr 09, 2021 9:26 am
'rk3326_header_miniloader_spiboot' file was generated by Rockchip. We've used it as it was.
Cool. If you ever want to update it, it looks like you can just build it according to the Rockchip Wiki with their updated binaries and write the resultant idbloader.img file to sector 128 instead of sector 64.

Post Reply

Return to “Platform development”

Who is online

Users browsing this forum: No registered users and 1 guest