#680 [grub] grub.cfg from core/memdisk improvements (not CBFS one)

Open
opened 1 year ago by swiftgeek · 0 comments
  • (NOT implemented yet) Reuse boot_devices RTC nvram variable to make grubtest.cfg testing more robust - when grubtest.cfg is loaded from grub.cfg, grub.cfg might load some module/perform something in way that was required for device operation, so when user replaces grub.cfg with grubtest.cfg it might lead to different behavior, than one when initially testing it. Also it should be actually sufficient to just use grubtest.cfg this way as there won't be any difference to swapping grub.cfg besides added recovery path that doesn't involve external reflashing - removing RTC battery will make it switch back to grub.cfg as RTC nvram is cleared. Proposed contents of the variable would be just filename without a path, or if impossible to sanitize - simple check whether variable is set to grubtest.cfg exactly

TODO: check for alternative lockable RTC nvram space

Current candidates:

  • reboot_counter
  • boot_devices
  • But this needs to work for any device, and offsets for each device are different?
    • this offset could be pulled from special file on cbfs
      • bit can be cleared immediately before loading grubtest.cfg
    • alternatively a current date could be written to cbfs file and if it's newer than system one, then that means RTC was reset.
  • Perhaps write a module that simply checks a checksum of NVRAM, and if NVRAM is invalid, ignore grubtest.cfg
  • Perhaps use date comparison, anything close to reset one (5 minutes) should ignore grubtest.cfg
    • but grub is built before coreboot, and it can't tell reset time of coreboot image to be built in future
  • Something passed in a coreboot table that would notify about RTC reset (not implemented)
  • RK808 doesn't have any RTC NVRAM for user! so besides date hack or coreboot exporting RTC being reset/re-powered, there is nothing that can be done that early!

TODO: check for possible nvramtool-like dependency

References:


If cbfs grub.cfg is not found, then sleep 3 and load minimal amount of modules to operate shell (keyboard)

* (NOT implemented yet) Reuse `boot_devices` RTC nvram variable to make `grubtest.cfg` testing more robust - when `grubtest.cfg` is loaded from `grub.cfg`, `grub.cfg` might load some module/perform something in way that was required for device operation, so when user replaces `grub.cfg` with `grubtest.cfg` it might lead to different behavior, than one when initially testing it. Also it should be actually sufficient to just use `grubtest.cfg` this way as there won't be any difference to swapping `grub.cfg` besides added recovery path that doesn't involve external reflashing - removing RTC battery will make it switch back to `grub.cfg` as RTC nvram is cleared. Proposed contents of the variable would be just filename without a path, or if impossible to sanitize - simple check whether variable is set to `grubtest.cfg` exactly TODO: check for alternative lockable RTC nvram space Current candidates: * `reboot_counter` * `boot_devices` * But this needs to work for any device, and offsets for each device are different? * this offset could be pulled from special file on cbfs * bit can be cleared immediately before loading grubtest.cfg * alternatively a current date could be written to cbfs file and if it's newer than system one, then that means RTC was reset. * Perhaps write a module that simply checks a checksum of NVRAM, and if NVRAM is invalid, ignore grubtest.cfg * Perhaps use date comparison, anything close to reset one (5 minutes) should ignore `grubtest.cfg` * but grub is built before coreboot, and it can't tell reset time of coreboot image to be built in future * Something passed in a coreboot table that would notify about RTC reset (not implemented) * **RK808 doesn't have any RTC NVRAM for user!** so besides date hack or coreboot exporting RTC being reset/re-powered, there is nothing that can be done that early! TODO: check for possible nvramtool-like dependency References: * [boot_devices variable use in FILO](https://www.coreboot.org/FILO#NVRAM_Parsing) * [cmos.layout](https://www.coreboot.org/CMOS.layout_guide) ----- If cbfs grub.cfg is not found, then sleep 3 and load minimal amount of modules to operate shell (keyboard)
Sign in to join this conversation.
Loading...
Cancel
Save
There is no content yet.