/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @file
* @brief Legacy flash fallbacks
*
* This file contains hacks for flash drivers without page layout
* support. They're hacks because they guess a page layout that may be
* incorrect, but is likely to "work". Needless to say, such guesswork
* is undesirable in trusted bootloader code.
*
* The behavior is:
*
* - If FLASH_AREA_IMAGE_SECTOR_SIZE is defined (this was used by
* older Zephyr ports), the image sectors have uniform sector sizes.
* We also assume that's the size of the scratch sectors.
*
* - Otherwise, we assume that the size of the entire scratch area is
* a least common multiple of all sector sizes, and use that as
* FLASH_AREA_IMAGE_SECTOR_SIZE.
*/
#include "bootutil/bootutil_log.h"
#include