Skip to content
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

[sw/silicon_creator] Add structured kChipInfo to ROM #18100

Merged
merged 3 commits into from May 1, 2023

Conversation

dmcardle
Copy link
Contributor

@dmcardle dmcardle commented Apr 20, 2023

This commit adds a new chip_info_t struct that contains info about the ROM's provenance. The ROM now prints the Git commit hash on shutdown after the "VER:" prefix.

The ROM linker script was already configured to place the .chip_info section at the top of ROM, but I'm not confident that it worked as expected. The autogenerated header contained a static constant, so I think a copy would be inlined at some arbitrary location into any compilation unit that used it, rather than being placed by the linker script.

To verify that the ROM prints the Git commit hash on shutdown:

./bazelisk.sh test --test_output=streamed \
  //sw/device/silicon_creator/rom/e2e:shutdown_output_dev_fpga_cw310_rom

To verify that the .chip_info section contains data from chip_info.o:

./bazelisk.sh build-then 'less %s' --config riscv32 \
  //sw/device/silicon_creator/rom:rom_with_fake_keys_fpga_cw310_map

To see the value of kChipInfo at the end of ROM:

./bazelisk.sh build-then 'xxd %s | less' --config riscv32 \
  //sw/device/silicon_creator/rom:rom_with_fake_keys_fpga_cw310_bin

For example, here's the end of the ROM from the previous command. At 0x7f80, there are 64 bits of a Git commit hash (e20871e1cf102bf6).

00007f70: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00007f80: f62b 10cf e171 08e2                      .+...q..

Fixes #14892
Further discussion in #18198

@dmcardle dmcardle requested a review from alphan April 20, 2023 20:57
@dmcardle dmcardle requested review from cfrantz and a team as code owners April 20, 2023 20:57
@dmcardle dmcardle removed the request for review from a team April 20, 2023 20:57
@dmcardle dmcardle force-pushed the dmcardle/chip_info branch 2 times, most recently from 4673b8f to 95fd0b8 Compare April 20, 2023 21:36
@alphan
Copy link
Contributor

alphan commented Apr 21, 2023

It looks like #17829 was merged recently. Can you rebase and check if it simplifies our lives?

@alphan
Copy link
Contributor

alphan commented Apr 21, 2023

The ROM linker script was already configured to place the .chip_info section at the top of ROM, but I'm not confident that it worked as expected. The autogenerated header contained a static constant, so I think a copy would be inlined at some arbitrary location into any compilation unit that used it, rather than being placed by the linker script.

While not ideal, I think it was fine (static constant in a header), linker is responsible for shuffling things at the end according to our linker scripts.

@dmcardle dmcardle force-pushed the dmcardle/chip_info branch 3 times, most recently from 9b26e6e to d123df0 Compare April 21, 2023 20:42
@dmcardle dmcardle force-pushed the dmcardle/chip_info branch 4 times, most recently from d91bb64 to 4df6a9c Compare April 25, 2023 14:14
@dmcardle
Copy link
Contributor Author

Hey @cfrantz, this is ready for a review when you get a chance!

@dmcardle dmcardle force-pushed the dmcardle/chip_info branch 2 times, most recently from 02af19c to 910d28c Compare April 25, 2023 19:16
util/rom_chip_info.py Outdated Show resolved Hide resolved
sw/device/silicon_creator/lib/chip_info.h Outdated Show resolved Hide resolved
util/BUILD Outdated Show resolved Hide resolved
util/rom_chip_info.py Outdated Show resolved Hide resolved
util/rom_chip_info.py Outdated Show resolved Hide resolved
sw/device/silicon_creator/lib/BUILD Show resolved Hide resolved
@moidx
Copy link
Contributor

moidx commented Apr 26, 2023

CC: @msfschaffner, HW_REV captured by ROM from lc_ctrl. Just as a reminder we should start a doc to track CHIP_GEN and CHIP_REV across the project.

@msfschaffner
Copy link
Contributor

CC: @msfschaffner, HW_REV captured by ROM from lc_ctrl. Just as a reminder we should start a doc to track CHIP_GEN and CHIP_REV across the project.

ACK

util/BUILD Outdated Show resolved Hide resolved
@dmcardle dmcardle force-pushed the dmcardle/chip_info branch 3 times, most recently from 3876c62 to 7181b67 Compare April 28, 2023 16:29
util/BUILD Outdated Show resolved Hide resolved
PR lowRISC#17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
PR lowRISC#17829 updated the FIFO size, but the constant in this macro was
still stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
This commit adds a new `chip_info_t` struct that contains info about the
ROM's provenance. The ROM now prints the Git commit hash on shutdown
after the "VER:" prefix.

The ROM linker script was already configured to place the .chip_info
section at the top of ROM, but I'm not confident that it worked as
expected. The autogenerated header contained a static constant, so I
think a copy would be inlined at some arbitrary location into any
compilation unit that used it, rather than being placed by the linker
script.

To verify that the ROM prints the Git commit hash on shutdown:

    ./bazelisk.sh test --test_output=streamed \
      //sw/device/silicon_creator/rom/e2e:shutdown_output_dev_fpga_cw310_rom

To verify that the .chip_info section contains data from chip_info.o:

    ./bazelisk.sh build-then 'less %s' --config riscv32 \
      //sw/device/silicon_creator/rom:rom_with_fake_keys_fpga_cw310_map

To see the value of `kChipInfo` at the end of ROM:

    ./bazelisk.sh build-then 'xxd %s | less' --config riscv32 \
      //sw/device/silicon_creator/rom:rom_with_fake_keys_fpga_cw310_bin

For example, here's the end of the ROM from the previous command. At
0x7f80, there are 64 bits of a Git commit hash (e20871e1cf102bf6).

    00007f70: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    00007f80: f62b 10cf e171 08e2                      .+...q..

Issue lowRISC#14892
Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
Copy link
Contributor

@alphan alphan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dmcardle !

@dmcardle dmcardle merged commit 2ecf53b into lowRISC:master May 1, 2023
23 checks passed
@dmcardle dmcardle deleted the dmcardle/chip_info branch May 1, 2023 20:27
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.

[sw/silicon_creator] ROM digest and chip_info
5 participants