Skip to content

Add support for Implied ApobNvCopy BHD directory entry #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

citrus-it
Copy link
Contributor

@citrus-it citrus-it commented Feb 7, 2025

In order to support eMCR - https://github.com/oxidecomputer/stlouis/issues/707

The flash address here is a placeholder, but it looks like the right thing was done:

atrium:helios:emcr% gmake turin-rubyred-1.0.0.2-p1.img PAYLOAD=../nanobl-rs/obj/nanobl-rs.elf
cargo run -- generate -s '16 MiB'  -v -B . -B amd-firmware/BRH/1.0.0.2-p1 -c etc/turin-rubyred-1.0.0.2-p1.efs.json5 -r ../nanobl-rs/obj/nanobl-rs.elf -o turin-rubyred-1.0.0.2-p1.img
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/amd-host-image-builder generate -s '16 MiB' -v -B . -B amd-firmware/BRH/1.0.0.2-p1 -c etc/turin-rubyred-1.0.0.2-p1.efs.json5 -r ../nanobl-rs/obj/nanobl-rs.elf -o turin-rubyred-1.0.0.2-p1.img`

atrium:helios:emcr% cargo run dump -i turin-rubyred-1.0.0.2-p1.img | grep -B3 -A13 Apob
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/amd-host-image-builder dump -i turin-rubyred-1.0.0.2-p1.img`
        {
          source: "Implied",
          target: {
            type: "Apob",
            region_type: "Normal",
            reset_image: false,
            copy_image: false,
            read_only: false,
            compressed: false,
            instance: 0,
            sub_program: 0,
            rom_id: "SpiCs1",
            flash_location: 0,
            size: 0,
            ram_destination_address: 67108864
          }
        },
        {
          source: "Implied",
          target: {
            type: "ApobNvCopy",
            region_type: "Normal",
            reset_image: false,
            copy_image: false,
            read_only: false,
            compressed: false,
            instance: 0,
            sub_program: 0,
            rom_id: "SpiCs1",
            flash_location: 305419896,
            size: 851968,
            ram_destination_address: null
          }
        },

@daym
Copy link
Collaborator

daym commented Feb 12, 2025

That flash_location seems to be about 291 MiB ? Uhh.

There's a limitation of my flash allocator as it is currently used: It can't do custom reserved ranges (but it can do reserved ranges in general and there is one used).

Therefore, specifying flash_location like that is not safe (except when you specify it for all items and for all the directories themselves--which is possible even in the json5 file!). The allocator will not exclude any explicitly specified flash_location .. (flash_location + size) range from the range it can allocate from in the future.

Are you sure that specifying flash_location like this is even required?

It might be that the allocator allocates anyway if you don't specify flash_location and don't specify a Blob source either--or could be easily be made to do that.

We should definitely add a test for that case now that we need it, though.

Or, the hacky solution would be since we only use 16 MiB of the flash anyway, set flash_location to above 16 MiB. Let's not do that, though.

@citrus-it
Copy link
Contributor Author

citrus-it commented Feb 12, 2025

For eMCR our plan was to add an ApobNvCopy entry that points to 64MiB which is a location in flash that's separately managed by the SP and should contain a cached copy of the APOB from the last boot.

The value in this draft PR is just a placeholder.
Because we currently need to apply an offset for flash access from the host on RubyRed (of 0x3000000), I have been using

                    flash_location: 0x7000000,

for testing. However, the ABL (specifically the PMU eMCR firmware) ends up trying to read from address 0x0 so it is either unhappy with this, or not finding it because I did not place it in the second level directory, and I think I may need to.

@daym
Copy link
Collaborator

daym commented Feb 12, 2025

I see!

There is pretty complete second level directory support in amd-host-image-builder by now--so we can try it with that.

@citrus-it
Copy link
Contributor Author

Yes, this is compiling, but the PSP doesn't seem to boot. I suspect I need to put more items in there like one of the stock ROMs.

+        {
+          source: {
+            SecondLevelDirectory: {
+              entries: [
+                {
+                  "source": "Implied",
+                  "target": {
+                    "type": "Apob",
+                    "ram_destination_address": 0x4000000
+                  }
+                },
+                {
+                  "source": "Implied",
+                  target: {
+                    type: "ApobNvCopy",
+                    flash_location: 0x7000000,
+                    size: 0xd0000
+                  }
+                }
+              ]
+            }
+          },
+          target: {
+            type: "SecondLevelDirectory"
+          }
+        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants