Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers flash_blob.c Source File

flash_blob.c

00001 /**
00002  * @file    flash_blob.c
00003  * @brief   Flash algorithm for the stm32f407
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
00007  * SPDX-License-Identifier: Apache-2.0
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  * not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  * http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #include "flash_blob.h"
00023 
00024 static const uint32_t stm32f4xx_512_flash_prog_blob[] = {
00025     0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
00026     0xf3c04601, 0x28203007, 0x2204bf24, 0x1050eb02, 0x2810d205, 0x2203bf26, 0x1010eb02, 0xf4110880,
00027     0xbf181f80, 0x0010f040, 0x486b4770, 0x60014969, 0x6001496a, 0x6801486a, 0x01f0f041, 0x48696001,
00028     0xf0106800, 0xd1080f20, 0xf2454867, 0x60015155, 0x60412106, 0x71fff640, 0x20006081, 0x49634770,
00029     0xf4206808, 0x600a52f8, 0x48616008, 0xf0416801, 0x60014100, 0x47702000, 0xc174f8df, 0x0000f8dc,
00030     0x0004f040, 0x0000f8cc, 0x0000f8dc, 0x3080f440, 0x0000f8cc, 0x0004f1ac, 0xf4116801, 0xbf1c3f80,
00031     0x21aaf64a, 0xd0044a50, 0x68036011, 0x3f80f413, 0xf8dcd1fa, 0xf0200000, 0xf8cc0004, 0x20000000,
00032     0xf3c04770, 0x29203107, 0x2204bf24, 0x1151eb02, 0x2910d205, 0x2203bf26, 0x1111eb02, 0xf4100889,
00033     0xbf181f80, 0x0110f041, 0x6802483d, 0x02f0f042, 0xf1006002, 0x22020c04, 0x2000f8cc, 0x2000f8dc,
00034     0xea0323f8, 0x431101c1, 0x1000f8cc, 0x1000f8dc, 0x3180f441, 0x1000f8cc, 0xf4116801, 0xbf1c3f80,
00035     0x21aaf64a, 0xd0044a30, 0x68036011, 0x3f80f413, 0xf8dcd1fa, 0xf0211000, 0xf8cc0102, 0x68011000,
00036     0x0ff0f011, 0x2000bf04, 0x68014770, 0x01f0f041, 0x20016001, 0x4b224770, 0x1cc9b430, 0xc000f8d3,
00037     0x0103f031, 0x0cf0f04c, 0xc000f8c3, 0x0404f103, 0x0c00f04f, 0xc000f8c4, 0xf240bf18, 0xd0252501,
00038     0xc000f8d4, 0x0c05ea4c, 0xc000f8c4, 0xc000f8d2, 0xc000f8c0, 0xc000f8d3, 0x3f80f41c, 0xf8d4d1fa,
00039     0xf02cc000, 0xf8c40c01, 0xf8d3c000, 0xf01cc000, 0xd0060ff0, 0xf0406818, 0x601800f0, 0x2001bc30,
00040     0x1d004770, 0xf1021f09, 0xd1d90204, 0x2000bc30, 0x00004770, 0x45670123, 0x40023c04, 0xcdef89ab,
00041     0x40023c0c, 0x40023c14, 0x40003000, 0x40023c00, 0x40023c10, 0x00000000
00042 };
00043 
00044 // Start address of flash
00045 static const uint32_t flash_start = 0x08000000;
00046 // Size of flash
00047 static const uint32_t flash_size = 0x00080000;
00048 
00049 /**
00050 * List of start and size for each size of flash sector - even indexes are start, odd are size
00051 * The size will apply to all sectors between the listed address and the next address
00052 * in the list.
00053 * The last pair in the list will have sectors starting at that address and ending
00054 * at address flash_start + flash_size.
00055 */
00056 static const sector_info_t sectors_info[] = {
00057     { 0x08000000, 0x00004000 },
00058     { 0x08010000, 0x00010000 },
00059     { 0x08020000, 0x00020000 },
00060 };
00061 
00062 static const program_target_t flash = {
00063     0x2000004b, // Init
00064     0x2000007f, // UnInit
00065     0x20000099, // EraseChip
00066     0x200000e3, // EraseSector
00067     0x20000177, // ProgramPage
00068     0,          // Verify
00069 
00070     // BKPT : start of blob + 1
00071     // RSB  : blob start + header + rw data offset
00072     // RSP  : stack pointer
00073     {
00074         0x20000001,
00075         0x20000214,
00076         0x20002000
00077     },
00078 
00079     0x20000000 + 0x00000A00,  // mem buffer location
00080     0x20000000,               // location to write prog_blob in target RAM
00081     sizeof(stm32f4xx_512_flash_prog_blob),   // prog_blob size
00082     stm32f4xx_512_flash_prog_blob,           // address of prog_blob
00083     0x00000400       // ram_to_flash_bytes_to_be_written
00084 };