Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
source/family/freescale/kl25z/flash_blob.c@0:01f31e923fe2, 2020-04-07 (annotated)
- Committer:
- Pawel Zarembski
- Date:
- Tue Apr 07 12:55:42 2020 +0200
- Revision:
- 0:01f31e923fe2
hani: DAPLink with reset workaround
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pawel Zarembski |
0:01f31e923fe2 | 1 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 2 | * @file flash_blob.c |
Pawel Zarembski |
0:01f31e923fe2 | 3 | * @brief Flash algorithm for the kl25z |
Pawel Zarembski |
0:01f31e923fe2 | 4 | * |
Pawel Zarembski |
0:01f31e923fe2 | 5 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 6 | * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 7 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 8 | * |
Pawel Zarembski |
0:01f31e923fe2 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 10 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 11 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 12 | * |
Pawel Zarembski |
0:01f31e923fe2 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 14 | * |
Pawel Zarembski |
0:01f31e923fe2 | 15 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 18 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 19 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 20 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 21 | |
Pawel Zarembski |
0:01f31e923fe2 | 22 | #include "flash_blob.h" |
Pawel Zarembski |
0:01f31e923fe2 | 23 | |
Pawel Zarembski |
0:01f31e923fe2 | 24 | static const uint32_t KL25Z_FLM[] = { |
Pawel Zarembski |
0:01f31e923fe2 | 25 | 0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2, |
Pawel Zarembski |
0:01f31e923fe2 | 26 | 0x4604b570, 0x4616460d, 0x49302000, 0x48306008, 0xf0004448, 0x2800f8e9, 0x2001d001, 0x2000bd70, |
Pawel Zarembski |
0:01f31e923fe2 | 27 | 0x4601e7fc, 0x47702000, 0x492ab510, 0x44484828, 0xf8c2f000, 0x2c004604, 0x2100d105, 0x44484824, |
Pawel Zarembski |
0:01f31e923fe2 | 28 | 0xf9bef000, 0xf0004604, 0x4620f838, 0xb570bd10, 0x481f4604, 0x4b1f4448, 0x68c24621, 0xf862f000, |
Pawel Zarembski |
0:01f31e923fe2 | 29 | 0x2d004605, 0x481ad107, 0x23004448, 0x68c24621, 0xf956f000, 0xf0004605, 0x4628f820, 0xb5febd70, |
Pawel Zarembski |
0:01f31e923fe2 | 30 | 0x460c4605, 0x46234616, 0x46294632, 0x44484810, 0xf90af000, 0x2f004607, 0x2201d10b, 0x46339001, |
Pawel Zarembski |
0:01f31e923fe2 | 31 | 0x90029200, 0x46294622, 0x44484809, 0xf99af000, 0xf0004607, 0x4638f802, 0x4807bdfe, 0x210168c0, |
Pawel Zarembski |
0:01f31e923fe2 | 32 | 0x43880289, 0x49041840, 0x477060c8, 0x40048100, 0x00000004, 0x6b65666b, 0xf0003000, 0x4a102070, |
Pawel Zarembski |
0:01f31e923fe2 | 33 | 0x20807010, 0xbf007010, 0x7800480d, 0x280009c0, 0x480bd0fa, 0x20207801, 0x28004008, 0x2067d001, |
Pawel Zarembski |
0:01f31e923fe2 | 34 | 0x20104770, 0x28004008, 0x2068d001, 0x07c8e7f8, 0x28000fc0, 0x2069d001, 0x2000e7f2, 0x0000e7f0, |
Pawel Zarembski |
0:01f31e923fe2 | 35 | 0x40020000, 0xb081b5ff, 0x460d4604, 0xf0009804, 0x4606f89f, 0xd0022e00, 0xb0054630, 0x2304bdf0, |
Pawel Zarembski |
0:01f31e923fe2 | 36 | 0x46204629, 0xf0009a03, 0x4606f876, 0xd0012e00, 0xe7f24630, 0x18289803, 0x46381e47, 0xf00068e1, |
Pawel Zarembski |
0:01f31e923fe2 | 37 | 0x2900f983, 0x4638d009, 0xf00068e1, 0x1c40f97d, 0x68e19000, 0x43489800, 0xe0131e47, 0x4478480c, |
Pawel Zarembski |
0:01f31e923fe2 | 38 | 0x60056800, 0x490b2009, 0xf7ff71c8, 0x4606ffa7, 0x280069a0, 0x69a0d001, 0x2e004780, 0xe003d000, |
Pawel Zarembski |
0:01f31e923fe2 | 39 | 0x194568e0, 0xd9e942bd, 0x4630bf00, 0x0000e7c5, 0x00000462, 0x40020000, 0x4604b570, 0x4628460d, |
Pawel Zarembski |
0:01f31e923fe2 | 40 | 0xf856f000, 0x2e004606, 0x4630d001, 0x2c00bd70, 0x2004d101, 0x2044e7fa, 0x71c84902, 0xff7ef7ff, |
Pawel Zarembski |
0:01f31e923fe2 | 41 | 0x0000e7f4, 0x40020000, 0x29004601, 0x2004d101, 0x482a4770, 0x010068c0, 0x00400f00, 0x447b4b28, |
Pawel Zarembski |
0:01f31e923fe2 | 42 | 0x03025a18, 0xd1012a00, 0xe7f12064, 0x60082000, 0x2001604a, 0x02806088, 0x200060c8, 0x61486108, |
Pawel Zarembski |
0:01f31e923fe2 | 43 | 0xbf006188, 0x4602e7e4, 0xd1012a00, 0x47702004, 0x20006191, 0xb530e7fb, 0x2c004604, 0x2004d101, |
Pawel Zarembski |
0:01f31e923fe2 | 44 | 0x1e58bd30, 0x28004008, 0x1e58d103, 0x28004010, 0x2065d001, 0x6820e7f4, 0xd8054288, 0x68206865, |
Pawel Zarembski |
0:01f31e923fe2 | 45 | 0x188d1940, 0xd20142a8, 0xe7e92066, 0xe7e72000, 0x480c4601, 0xd0014281, 0x4770206b, 0xe7fc2000, |
Pawel Zarembski |
0:01f31e923fe2 | 46 | 0x2b004603, 0x2004d101, 0x290f4770, 0x2a04d801, 0x2004d001, 0x2000e7f8, 0x0000e7f6, 0x40048040, |
Pawel Zarembski |
0:01f31e923fe2 | 47 | 0x000003c0, 0x6b65666b, 0xb081b5ff, 0x46144607, 0x2c00461d, 0x2004d102, 0xbdf0b005, 0x462a2304, |
Pawel Zarembski |
0:01f31e923fe2 | 48 | 0x99024638, 0xffb7f7ff, 0x2e004606, 0x4630d001, 0xe01ce7f2, 0x44794910, 0x68099802, 0xcc016008, |
Pawel Zarembski |
0:01f31e923fe2 | 49 | 0x4479490d, 0x6809390c, 0x20066048, 0x71c8490b, 0xfef4f7ff, 0x69b84606, 0xd0012800, 0x478069b8, |
Pawel Zarembski |
0:01f31e923fe2 | 50 | 0xd0002e00, 0x9802e005, 0x90021d00, 0x2d001f2d, 0xbf00d1e0, 0xe7cf4630, 0x0000030a, 0x40020000, |
Pawel Zarembski |
0:01f31e923fe2 | 51 | 0xb083b5ff, 0x2304460c, 0x9a054621, 0xf7ff9803, 0x9002ff82, 0x28009802, 0x9802d002, 0xbdf0b007, |
Pawel Zarembski |
0:01f31e923fe2 | 52 | 0x68919a03, 0xf0006850, 0x4605f88f, 0x42684261, 0x424e4001, 0xd10042a6, 0x9f051976, 0x1b30e027, |
Pawel Zarembski |
0:01f31e923fe2 | 53 | 0x98019001, 0xd90042b8, 0x98019701, 0x90000880, 0x44784811, 0x60046800, 0x49102001, 0x980071c8, |
Pawel Zarembski |
0:01f31e923fe2 | 54 | 0x0e010400, 0x72c1480d, 0x9800490c, 0x98067288, 0xf7ff7248, 0x9002fea3, 0x28009802, 0x9802d001, |
Pawel Zarembski |
0:01f31e923fe2 | 55 | 0x9801e7cc, 0x98011a3f, 0x19761824, 0x2f00bf00, 0x2000d1d5, 0x0000e7c2, 0x0000026e, 0x40020000, |
Pawel Zarembski |
0:01f31e923fe2 | 56 | 0x4604b570, 0x2c00460d, 0x2004d101, 0x2040bd70, 0x71c84903, 0x71854608, 0xfe80f7ff, 0x0000e7f6, |
Pawel Zarembski |
0:01f31e923fe2 | 57 | 0x40020000, 0xb081b5ff, 0x4617460c, 0x2d00461d, 0x2004d102, 0xbdf0b005, 0x463a2304, 0x98014621, |
Pawel Zarembski |
0:01f31e923fe2 | 58 | 0xff19f7ff, 0x2e004606, 0x4630d001, 0xe022e7f2, 0x44784813, 0x60046800, 0x49122002, 0x980a71c8, |
Pawel Zarembski |
0:01f31e923fe2 | 59 | 0x490f72c8, 0x39124479, 0x68096828, 0xf7ff6088, 0x4606fe55, 0xd00b2e00, 0x2800980b, 0x980bd001, |
Pawel Zarembski |
0:01f31e923fe2 | 60 | 0x980c6004, 0xd0022800, 0x980c2100, 0xe0046001, 0x1d2d1f3f, 0x2f001d24, 0xbf00d1da, 0xe7c94630, |
Pawel Zarembski |
0:01f31e923fe2 | 61 | 0x000001ce, 0x40020000, 0x09032200, 0xd32c428b, 0x428b0a03, 0x2300d311, 0xe04e469c, 0x430b4603, |
Pawel Zarembski |
0:01f31e923fe2 | 62 | 0x2200d43c, 0x428b0843, 0x0903d331, 0xd31c428b, 0x428b0a03, 0x4694d301, 0x09c3e03f, 0xd301428b, |
Pawel Zarembski |
0:01f31e923fe2 | 63 | 0x1ac001cb, 0x09834152, 0xd301428b, 0x1ac0018b, 0x09434152, 0xd301428b, 0x1ac0014b, 0x09034152, |
Pawel Zarembski |
0:01f31e923fe2 | 64 | 0xd301428b, 0x1ac0010b, 0x08c34152, 0xd301428b, 0x1ac000cb, 0x08834152, 0xd301428b, 0x1ac0008b, |
Pawel Zarembski |
0:01f31e923fe2 | 65 | 0x08434152, 0xd301428b, 0x1ac0004b, 0x1a414152, 0x4601d200, 0x46104152, 0xe05d4770, 0xd0000fca, |
Pawel Zarembski |
0:01f31e923fe2 | 66 | 0x10034249, 0x4240d300, 0x22004053, 0x0903469c, 0xd32d428b, 0x428b0a03, 0x22fcd312, 0xba120189, |
Pawel Zarembski |
0:01f31e923fe2 | 67 | 0x428b0a03, 0x0189d30c, 0x428b1192, 0x0189d308, 0x428b1192, 0x0189d304, 0x1192d03a, 0x0989e000, |
Pawel Zarembski |
0:01f31e923fe2 | 68 | 0x428b09c3, 0x01cbd301, 0x41521ac0, 0x428b0983, 0x018bd301, 0x41521ac0, 0x428b0943, 0x014bd301, |
Pawel Zarembski |
0:01f31e923fe2 | 69 | 0x41521ac0, 0x428b0903, 0x010bd301, 0x41521ac0, 0x428b08c3, 0x00cbd301, 0x41521ac0, 0x428b0883, |
Pawel Zarembski |
0:01f31e923fe2 | 70 | 0x008bd301, 0x41521ac0, 0x0843d2d9, 0xd301428b, 0x1ac0004b, 0x1a414152, 0x4601d200, 0x41524663, |
Pawel Zarembski |
0:01f31e923fe2 | 71 | 0x4610105b, 0x4240d301, 0xd5002b00, 0x47704249, 0x105b4663, 0x4240d300, 0x2000b501, 0x46c046c0, |
Pawel Zarembski |
0:01f31e923fe2 | 72 | 0x0002bd02, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000000, 0x00000000, |
Pawel Zarembski |
0:01f31e923fe2 | 73 | 0x00000020, 0x40020004, 0x00000000, |
Pawel Zarembski |
0:01f31e923fe2 | 74 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 75 | |
Pawel Zarembski |
0:01f31e923fe2 | 76 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 77 | * List of start and size for each size of flash sector |
Pawel Zarembski |
0:01f31e923fe2 | 78 | * The size will apply to all sectors between the listed address and the next address |
Pawel Zarembski |
0:01f31e923fe2 | 79 | * in the list. |
Pawel Zarembski |
0:01f31e923fe2 | 80 | * The last pair in the list will have sectors starting at that address and ending |
Pawel Zarembski |
0:01f31e923fe2 | 81 | * at address start + size. |
Pawel Zarembski |
0:01f31e923fe2 | 82 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 83 | static const sector_info_t sectors_info[] = { |
Pawel Zarembski |
0:01f31e923fe2 | 84 | {0, 1024}, |
Pawel Zarembski |
0:01f31e923fe2 | 85 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 86 | |
Pawel Zarembski |
0:01f31e923fe2 | 87 | static const program_target_t flash = { |
Pawel Zarembski |
0:01f31e923fe2 | 88 | 0x20000021, // Init |
Pawel Zarembski |
0:01f31e923fe2 | 89 | 0x20000039, // UnInit |
Pawel Zarembski |
0:01f31e923fe2 | 90 | 0x20000049, // EraseChip |
Pawel Zarembski |
0:01f31e923fe2 | 91 | 0x2000006F, // EraseSector |
Pawel Zarembski |
0:01f31e923fe2 | 92 | 0x2000009F, // ProgramPage |
Pawel Zarembski |
0:01f31e923fe2 | 93 | 0x0, // Verify |
Pawel Zarembski |
0:01f31e923fe2 | 94 | |
Pawel Zarembski |
0:01f31e923fe2 | 95 | // breakpoint = RAM start + 1 |
Pawel Zarembski |
0:01f31e923fe2 | 96 | // RSB : base address is address of Execution Region PrgData in map file |
Pawel Zarembski |
0:01f31e923fe2 | 97 | // to access global/static data |
Pawel Zarembski |
0:01f31e923fe2 | 98 | // RSP : Initial stack pointer |
Pawel Zarembski |
0:01f31e923fe2 | 99 | { |
Pawel Zarembski |
0:01f31e923fe2 | 100 | 0x20000001, // breakpoint instruction address |
Pawel Zarembski |
0:01f31e923fe2 | 101 | 0x20000000 + 0x20 + 0x5E8, // static base register value (image start + header + static base offset) |
Pawel Zarembski |
0:01f31e923fe2 | 102 | 0x20000800 // initial stack pointer |
Pawel Zarembski |
0:01f31e923fe2 | 103 | }, |
Pawel Zarembski |
0:01f31e923fe2 | 104 | |
Pawel Zarembski |
0:01f31e923fe2 | 105 | 0x20000a00, // program_buffer, any valid RAM location with +512 bytes of headroom |
Pawel Zarembski |
0:01f31e923fe2 | 106 | 0x20000000, // algo_start, start of RAM |
Pawel Zarembski |
0:01f31e923fe2 | 107 | sizeof(KL25Z_FLM), // algo_size, size of array above |
Pawel Zarembski |
0:01f31e923fe2 | 108 | KL25Z_FLM, // image, flash algo instruction array |
Pawel Zarembski |
0:01f31e923fe2 | 109 | 512 // ram_to_flash_bytes_to_be_written |
Pawel Zarembski |
0:01f31e923fe2 | 110 | }; |