| # Copyright 2021 The ChromiumOS Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| description "Flash ro of hps before hpsd starts" | |
| author "chromium-os-dev@chromium.org" | |
| # hpsd will still start if this fails | |
| # we could add this to hpsd.conf if needed: | |
| # start on stopped hpsd_roflash RESULT=ok | |
| start on starting hpsd | |
| task | |
| # This must not be killed as there is a small chance | |
| # it could leave the HPS device bricked. | |
| oom score never | |
| # Typical vsize for hps-factory is 2756 KiB, allow some headroom | |
| limit as 20000000 unlimited | |
| # Initialise the HPS before starting hpsd. The hps-factory command will: | |
| # 1. Unbind the cros-hps kernel driver, which will power *on* the HPS | |
| # peripheral on its way out. | |
| # 2. If HPS is in the STM bootloader (I2C address 0x51) because its flash is | |
| # blank, write stage0. If HPS is already in stage0 (I2C address 0x30), | |
| # check the stage0 version register, and erase and re-write stage0 if the | |
| # version is different. | |
| # 3. Bind the cros-hps kernel driver. | |
| script | |
| syslog-cat --identifier="${UPSTART_JOB}" -- \ | |
| hps-factory --dev=/dev/i2c-hps-controller \ | |
| write-stage0 --check-version --skip-one-time-init | |
| end script |