blob: b581a9ba9fd5d007132319039a9c71c38b44252d [file] [log] [blame]
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# 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
# It is OK for this to be killed, restarting will recover
oom score -100
# A trial run used 1.6 Mbytes. * 100 headroom
limit as 160000000 unlimited
env MMIO_ADDR=0xfd6a0ae0
env FLASH_ADDR=0x08000400
env I2C_BUS_NUMBER=15
env STAGE0_FIRMWARE=/usr/lib/firmware/hps/mcu_stage0.bin
# toggle power to reboot to the stm bootloader, flash, and boot
script
iotools mmio_write32 "${MMIO_ADDR}" \
$(iotools btr $(iotools mmio_read32 "${MMIO_ADDR}") 0) \
&& iotools mmio_write32 "${MMIO_ADDR}" \
$(iotools bts $(iotools mmio_read32 "${MMIO_ADDR}") 0) \
&& syslog-cat --identifier="${UPSTART_JOB}" -- \
stm32flash "/dev/i2c-${I2C_BUS_NUMBER}" -a 0x51 -v -S "${FLASH_ADDR}" \
-w "${STAGE0_FIRMWARE}" \
&& syslog-cat --identifier="${UPSTART_JOB}" -- \
stm32flash "/dev/i2c-${I2C_BUS_NUMBER}" -a 0x51 -g "${FLASH_ADDR}"
end script