Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:04

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup lpc32xx_boot
0007  *
0008  * @brief Boot support API.
0009  */
0010 
0011 /*
0012  * Copyright (c) 2010 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef LIBBSP_ARM_LPC32XX_BOOT_H
0037 #define LIBBSP_ARM_LPC32XX_BOOT_H
0038 
0039 #include <stdint.h>
0040 
0041 #ifdef __cplusplus
0042 extern "C" {
0043 #endif /* __cplusplus */
0044 
0045 /**
0046  * @defgroup lpc32xx_boot Boot Support
0047  *
0048  * @ingroup RTEMSBSPsARMLPC32XX
0049  *
0050  * @brief Boot support.
0051  *
0052  * The NXP internal boot program shall be the "stage-0 program".
0053  *
0054  * The boot program within the first page of the first or second block shall be
0055  * "stage-1 program".  It will be invoked by the stage-0 program from NXP.
0056  *
0057  * The program loaded by the stage-1 program will be the "stage-2 program" or the
0058  * "boot loader".
0059  *
0060  * The program loaded by the stage-2 program will be the "stage-3 program" or the
0061  * "application".
0062  *
0063  * The stage-1 program image must have a format specified by NXP.
0064  *
0065  * The stage-2 and stage-3 program images may have any format.
0066  *
0067  * @{
0068  */
0069 
0070 #define LPC32XX_BOOT_BLOCK_0 0
0071 #define LPC32XX_BOOT_BLOCK_1 1
0072 
0073 #define LPC32XX_BOOT_ICR_SP_3AC_8IF 0xf0
0074 #define LPC32XX_BOOT_ICR_SP_4AC_8IF 0xd2
0075 #define LPC32XX_BOOT_ICR_LP_4AC_8IF 0xb4
0076 #define LPC32XX_BOOT_ICR_LP_5AC_8IF 0x96
0077 
0078 typedef union {
0079   struct {
0080     uint8_t d0;
0081     uint8_t reserved_0 [3];
0082     uint8_t d1;
0083     uint8_t reserved_1 [3];
0084     uint8_t d2;
0085     uint8_t reserved_2 [3];
0086     uint8_t d3;
0087     uint8_t reserved_3 [3];
0088     uint8_t d4;
0089     uint8_t reserved_4 [3];
0090     uint8_t d5;
0091     uint8_t reserved_5 [3];
0092     uint8_t d6;
0093     uint8_t reserved_6 [3];
0094     uint8_t d7;
0095     uint8_t reserved_7 [3];
0096     uint8_t d8;
0097     uint8_t reserved_8 [3];
0098     uint8_t d9;
0099     uint8_t reserved_9 [3];
0100     uint8_t d10;
0101     uint8_t reserved_10 [3];
0102     uint8_t d11;
0103     uint8_t reserved_11 [3];
0104     uint8_t d12;
0105     uint8_t reserved_12 [463];
0106   } field;
0107   uint32_t data [128];
0108 } lpc32xx_boot_block;
0109 
0110 void lpc32xx_setup_boot_block(
0111   lpc32xx_boot_block *boot_block,
0112   uint8_t icr,
0113   uint8_t page_count
0114 );
0115 
0116 void lpc32xx_set_boot_block_bad(
0117   lpc32xx_boot_block *boot_block
0118 );
0119 
0120 /** @} */
0121 
0122 #ifdef __cplusplus
0123 }
0124 #endif /* __cplusplus */
0125 
0126 #endif /* LIBBSP_ARM_LPC32XX_BOOT_H */