<meta http-equiv="Content-Type" content="text/html; charset=GB18030"><div><div>Hi, Milton</div><div><br></div><div>Thanks a lot. It realy helps me a lot. Thanks again.</div><div><br></div><div>Best Regards!</div><div>Liu Hongwei</div></div><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ 原始邮件 ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>发件人:</b> "Milton Miller II"<miltonm@us.ibm.com>;</div><div><b>发送时间:</b> 2020年3月3日(星期二) 上午9:34</div><div><b>收件人:</b> "南野ムルシエラゴ"<1181052146@qq.com>;<wbr></div><div><b>抄送:</b> "openbmc"<openbmc@lists.ozlabs.org>;<wbr></div><div><b>主题:</b> Re:  What does openbmc system do after update BMC Firmware and taps reboot?</div></div><div><br></div>Around 03/02/2020 01:30AM in some timezone,  "南野ムルシエラゴ" <1181052146@qq.com> wrote:<br><br>>Greetings:<br>><br>>I am learning how openbmc update BMC firmware. I am following the<br>>guide<br>>"https://github.com/openbmc/docs/blob/master/code-update/code-update.<br>>md" to update BMC Firmware. It works well for me.<br>>But I still do not know, why in step 7 should I reboot, and what<br>>reboot do?<br><br>The low level workings was described better in the deprecated API <br>documentation; as it says only the API is deprecated and not the <br>underlying mechanism.  <br><br>https://github.com/openbmc/docs/blob/master/code-update/code-update-deprecated.md#preparing-for-bmc-code-update<br><br>>Later I found in<br>>"https://github.com/openbmc/docs/blob/master/code-update/code-update-<br>>diagrams.md", which tells that:<br>>        [*] In a static layout configuration, the images are stored<br>>in RAM and the content is written to flash during BMC reboot. <br>>        Reference the update and shutdown scripts provided by<br>>initrdscripts<br><br><br><br>>I am using a static layout. And I found two scripts named "shutdown"<br>>and "update" in "/run/initramfs/". So I thought it is that, the<br>>update applications put the firmware image in /run/initramfs/ and<br>>when I tap reboot, by some means the "update" script runs and the<br>>"update" script using "flashcp" command to write the firmware image<br>>to the /dev/mtd. Is that right?<br><br>Yes, the shutdown script is invoked by systemd and undoes the overlay <br>mount.  This happends for both reboot and shutdown.<br><br>See the third bullet here<br><br>https://www.freedesktop.org/wiki/Software/systemd/InitrdInterface/<br><br><br>>What happens after I tap "reboot", and who calls the "update" script,<br>>and how it calls the "update" scripts?<br><br>The shutdown script finishes unmounting the overlay, from which initrd<br>was running.  The shutdown script just runs using the busybox and libc.<br>The shutdown scripts notices the files in /run/initramfs and calls the<br>update script.<br><br><br>There is a big reason to do this at shutdown:   Its very unwise to try <br>to run off a file system while the file system raw media is being <br>replaced.<br><br>For a static layout, there is only flash space for one copy.  The init<br>script can make a separate copy (the deprecated API doc explains how) <br>and then you can erase and flash at runtime (with full services and<br>network to monitor progress).  The update script will automatically <br>detect the code-update mode; don't try to fake it out you will only<br>crash the machine.<br><br>If you want your bmc to be online set update mode and reboot (it gets <br>unset for the next boot every boot).  (I've seen slow flash take <br>30 minutes to erase; others take just few minutes).<br><br>>Can someone tell me? Thanks a lot!<br><br>Feel free to ask more questions I try to answer questions in this area<br>daily. (I'm the author of the low level mechanism; the code-update API <br>was written by others).<br><br>><br>>Best Regards!<br>>Liu Hongwei<br>><br><br>milton<br><br></div>