Contiki-NG
Loading...
Searching...
No Matches
flash.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3 * All rights reserved.
4 *
5 * Copyright (c) 2013, ADVANSEE - http://www.advansee.com/
6 * Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * 3. Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33 * OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35/**
36 * \addtogroup cc2538
37 * @{
38 *
39 * \defgroup cc2538-flash cc2538 flash memory
40 *
41 * Definitions for the cc2538 flash memory
42 * @{
43 *
44 * \file
45 * Header file for the flash memory definitions
46 */
47#ifndef FLASH_H_
48#define FLASH_H_
49
50#include "dev/cc2538-dev.h"
51#include "cfs-coffee-arch.h"
52
53#include <stdint.h>
54/*---------------------------------------------------------------------------*/
55/** \name Flash memory organization
56 * @{
57 */
58#define FLASH_PAGE_SIZE 2048
59#define FLASH_WORD_SIZE 4
60/** @} */
61/*---------------------------------------------------------------------------*/
62/** \name Flash lock bit page and CCA location
63 * @{
64 */
65#define FLASH_CCA_ADDR (CC2538_DEV_FLASH_ADDR + CC2538_DEV_FLASH_SIZE - \
66 FLASH_CCA_SIZE) /**< Address */
67#define FLASH_CCA_SIZE 0x0000002C /**< Size in bytes */
68/** @} */
69/*---------------------------------------------------------------------------*/
70/** \name Bootloader backdoor configuration bit fields
71 * @{
72 */
73#define FLASH_CCA_BOOTLDR_CFG_DISABLE 0xEFFFFFFF /**< Disable backdoor function */
74#define FLASH_CCA_BOOTLDR_CFG_ENABLE 0xF0FFFFFF /**< Enable backdoor function */
75#define FLASH_CCA_BOOTLDR_CFG_ACTIVE_HIGH 0x08000000 /**< Selected pin on pad A active high */
76#define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_M 0x07000000 /**< Selected pin on pad A mask */
77#define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S 24 /**< Selected pin on pad A shift */
78/** @} */
79/*---------------------------------------------------------------------------*/
80/** \name Image valid definitions
81 * @{
82 */
83#define FLASH_CCA_IMAGE_VALID 0x00000000 /**< Indicates valid image in flash */
84/** @} */
85/*---------------------------------------------------------------------------*/
86/** \name Lock page / debug definitions
87 * @{
88 */
89#define FLASH_CCA_LOCKED 0 /**< Page or debug locked if bit == 0 */
90#define FLASH_CCA_LOCK_DEBUG_BYTE 31 /**< Lock byte containing the debug lock bit */
91#define FLASH_CCA_LOCK_DEBUG_BIT 7 /**< Debug lock bit position in the corresponding lock byte */
92/** @} */
93/*---------------------------------------------------------------------------*/
94/** \name Firmware location in flash memory
95 * @{
96 */
97#ifdef FLASH_CONF_FW_ADDR
98#define FLASH_FW_ADDR FLASH_CONF_FW_ADDR
99#elif !defined(COFFEE_CONF_CUSTOM_PORT)
100#define FLASH_FW_ADDR (COFFEE_START + COFFEE_SIZE)
101#else
102#define FLASH_FW_ADDR CC2538_DEV_FLASH_ADDR
103#endif
104#ifdef FLASH_CONF_FW_SIZE
105#define FLASH_FW_SIZE FLASH_CONF_FW_SIZE
106#else
107#define FLASH_FW_SIZE (FLASH_CCA_ADDR - FLASH_FW_ADDR)
108#endif
109/** @} */
110/*---------------------------------------------------------------------------*/
111/** \name Flash lock bit page and CCA layout
112 * @{
113 */
114typedef struct {
115 uint32_t bootldr_cfg; /**< Bootloader backdoor configuration (page bytes 2004 - 2007) */
116 uint32_t image_valid; /**< Image valid (page bytes 2008 - 2011) */
117 const void *app_entry_point; /**< Flash vector table address (page bytes 2012 - 2015) */
118 uint8_t lock[32]; /**< Page and debug lock bits (page bytes 2016 - 2047) */
119} flash_cca_lock_page_t;
120/** @} */
121
122#endif /* FLASH_H_ */
123
124/**
125 * @}
126 * @}
127 */
Header file for the cc2538 devices definitions.