|
| 1 | +/** |
| 2 | + * @file flash_blob.c |
| 3 | + * @brief Flash algorithm for the MAX32670 |
| 4 | + * |
| 5 | + * DAPLink Interface Firmware |
| 6 | + * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved |
| 7 | + * SPDX-License-Identifier: Apache-2.0 |
| 8 | + * |
| 9 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 10 | + * not use this file except in compliance with the License. |
| 11 | + * You may obtain a copy of the License at |
| 12 | + * |
| 13 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | + * |
| 15 | + * Unless required by applicable law or agreed to in writing, software |
| 16 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 17 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | + * See the License for the specific language governing permissions and |
| 19 | + * limitations under the License. |
| 20 | + */ |
| 21 | + |
| 22 | +#include "flash_blob.h" |
| 23 | + |
| 24 | +#define FLC_BASE 0x40029000 |
| 25 | +#define CLOCK_DIV 0x00000060 |
| 26 | +#define BURST_SIZE 0x00000080 |
| 27 | +#define FLASH_BASE 0x10000000 |
| 28 | +#define FLASH_SIZE KB(384) |
| 29 | +#define FLASH_SECTOR KB(8) |
| 30 | + |
| 31 | +static const uint32_t flash_algo_blob[] = { |
| 32 | + 0xE00ABE00, |
| 33 | + 0x44494975, 0x68826808, 0x0f07f012, 0x2001bf1c, 0x68494770, 0x20006041, 0x486f4770, 0x68004448, |
| 34 | + 0xf0216881, 0x60814170, 0x47702000, 0xb510486a, 0x68044448, 0xf8b4f000, 0x68a0b9b0, 0x407ff420, |
| 35 | + 0x402af440, 0x68a060a0, 0x0002f040, 0x68a060a0, 0x0f02f010, 0x68a0d1fb, 0x4070f020, 0x6a6060a0, |
| 36 | + 0x0002f010, 0xbd10bf08, 0xbd102001, 0x4605b570, 0x44484859, 0xf0006804, 0xb9b8f893, 0xf42068a0, |
| 37 | + 0xf440407f, 0x60a040aa, 0x68a06025, 0x0004f040, 0x68a060a0, 0x0f04f010, 0x68a0d1fb, 0x4070f020, |
| 38 | + 0x6a6060a0, 0x0002f010, 0xbd70bf08, 0xbd702001, 0x41f0e92d, 0x8120f8df, 0x44c8460d, 0xf8d84606, |
| 39 | + 0x46174000, 0x0f03f012, 0xf000d167, 0x2800f869, 0xe00dd163, 0xf8576026, 0x63200b04, 0xf04068a0, |
| 40 | + 0x60a00001, 0xf01068a0, 0xd1fb0f01, 0x1d361f2d, 0xd3022d04, 0x0f1ff016, 0xf8d8d1ec, 0x28800008, |
| 41 | + 0x2d10d11a, 0x6026d318, 0x0b04f857, 0xf8576320, 0x63600b04, 0x0b04f857, 0xf85763a0, 0x63e00b04, |
| 42 | + 0xf04068a0, 0x60a00001, 0xf01068a0, 0xd1fb0f01, 0x36103d10, 0xd2e62d10, 0xd30f2d04, 0xf8576026, |
| 43 | + 0x63200b04, 0xf04068a0, 0x60a00001, 0xf01068a0, 0xd1fb0f01, 0x1d361f2d, 0xd2ef2d04, 0x683ab19d, |
| 44 | + 0x31fff04f, 0xea6220ff, 0x40190300, 0x1e6d0200, 0x6026d1f9, 0x68a06321, 0x0001f040, 0x68a060a0, |
| 45 | + 0x0f01f010, 0x68a0d1fb, 0x4070f020, 0x6a6060a0, 0x0002f010, 0xe8bdbf08, 0x200181f0, 0x81f0e8bd, |
| 46 | + 0x4448480d, 0x68816800, 0x0f07f011, 0x6a41d109, 0x2100b149, 0x6a416241, 0x2102b129, 0x6a416241, |
| 47 | + 0x2001b109, 0x68814770, 0x4170f021, 0x5100f041, 0x20006081, 0x00004770, 0x00000004, 0x00000000, |
| 48 | + FLC_BASE, CLOCK_DIV, BURST_SIZE, |
| 49 | +}; |
| 50 | + |
| 51 | +/** |
| 52 | +* List of start and size for each size of flash sector - even indexes are start, odd are size |
| 53 | +* The size will apply to all sectors between the listed address and the next address |
| 54 | +* in the list. |
| 55 | +* The last pair in the list will have sectors starting at that address and ending |
| 56 | +* at address flash_start + flash_size. |
| 57 | +*/ |
| 58 | +static const sector_info_t sectors_info[] = { |
| 59 | + FLASH_BASE, FLASH_SECTOR, |
| 60 | +}; |
| 61 | + |
| 62 | +static const program_target_t flash = { |
| 63 | + 0x20000005, // Init |
| 64 | + 0x2000001f, // UnInit |
| 65 | + 0x20000031, // EraseChip |
| 66 | + 0x20000071, // EraseSector |
| 67 | + 0x200000b5, // ProgramPage |
| 68 | + 0x00000000, // Verify |
| 69 | + |
| 70 | + // BKPT : start of blob + 1 |
| 71 | + // RSB : blob start + header + rw data offset |
| 72 | + // RSP : stack pointer |
| 73 | + { |
| 74 | + 0x20000001, |
| 75 | + 0x200001e0, |
| 76 | + 0x20000400 |
| 77 | + }, |
| 78 | + |
| 79 | + 0x20000000 + 0x00000A00, // mem buffer location |
| 80 | + 0x20000000, // location to write prog_blob in target RAM |
| 81 | + sizeof(flash_algo_blob), // prog_blob size |
| 82 | + flash_algo_blob, // address of prog_blob |
| 83 | + 0x00002000 // ram_to_flash_bytes_to_be_written |
| 84 | +}; |
0 commit comments