1 /******************************************************************************
3 * Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************/
37 #include "flashloader.h"
39 /* Data buffers used by host to communicate with flashloader */
41 /* Flashloader parameter structure. */
42 __attribute__ ((section(".buffers.g_cfg")))
43 volatile struct flash_params g_cfg
[2];
45 __attribute__ ((section(".buffers.g_buf1")))
46 uint8_t g_buf1
[BUFFER_LEN
];
48 __attribute__ ((section(".buffers.g_buf2")))
49 uint8_t g_buf2
[BUFFER_LEN
];
51 /* Buffer used for program with retain feature */
52 __attribute__ ((section(".buffers.g_retain_buf")))
53 uint8_t g_retain_buf
[BUFFER_LEN
];
55 uint32_t g_curr_buf
; /* Current buffer used. */
56 uint32_t g_vims_ctl
; /* Saved flash cache state. */
58 /******************************************************************************
60 * This function stores the current VIMS configuration before
61 * - disabling VIMS flash cache
62 * - flushing the flash line buffers.
64 * Note Not using driverlib calls because it requires using "NO_ROM" define in
65 * order to work for both Cha. R1 and R2 using the same code. Manually
66 * doing the steps to minimize code footprint.
68 ******************************************************************************/
69 static void disable_flash_cache()
71 /* 1. Make sure VIMS is not currently changing mode (VIMS:STAT register) */
72 while ((HWREG(0x40034000) & 0x00000008) == 0x8)
75 /* Save current VIMS:CTL state */
76 g_vims_ctl
= HWREG(0x40034004);
78 /* 2. Set VIMS mode to OFF and disable flash line buffers */
79 uint32_t new_vims_ctl
= g_vims_ctl
| 0x33;
80 HWREG(0x40034004) = new_vims_ctl
;
82 /* 3. Wait for VIMS to have changed mode (VIMS:STAT register) */
83 while ((HWREG(0x40034000) & 0x00000008) == 0x8)
87 /******************************************************************************
89 * This function restores the VIMS configuration saved off by
90 * disable_flash_cache().
92 * Note Not using driverlib calls because it requires using "NO_ROM" define in
93 * order to work for both Cha. R1 and R2 using the same code. Manually
94 * doing the steps to minimize code footprint.
96 ******************************************************************************/
97 static void restore_cache_state()
99 HWREG(0x40034004) = g_vims_ctl
;
101 /* Wait for VIMS to have changed mode (VIMS:STAT register) */
102 while ((HWREG(0x40034000) & 0x00000008) == 0x8)
106 /******************************************************************************
108 * CC13xx/CC26xx flashloader main function.
110 ******************************************************************************/
113 flashloader_init((struct flash_params
*)g_cfg
, g_buf1
, g_buf2
);
115 g_curr_buf
= 0; /* start with the first buffer */
119 /* Wait for host to signal buffer is ready */
120 while (g_cfg
[g_curr_buf
].full
== BUFFER_EMPTY
)
123 disable_flash_cache();
125 /* Perform requested task */
126 switch (g_cfg
[g_curr_buf
].cmd
) {
128 status
= flashloader_erase_all();
133 (uint8_t *)g_cfg
[g_curr_buf
].buf_addr
,
134 g_cfg
[g_curr_buf
].dest
, g_cfg
[g_curr_buf
].len
);
136 case CMD_ERASE_AND_PROGRAM
:
138 flashloader_erase_and_program(
139 (uint8_t *)g_cfg
[g_curr_buf
].buf_addr
,
140 g_cfg
[g_curr_buf
].dest
, g_cfg
[g_curr_buf
].len
);
142 case CMD_ERASE_AND_PROGRAM_WITH_RETAIN
:
144 flashloader_program_with_retain(
145 (uint8_t *)g_cfg
[g_curr_buf
].buf_addr
,
146 g_cfg
[g_curr_buf
].dest
, g_cfg
[g_curr_buf
].len
);
148 case CMD_ERASE_SECTORS
:
150 flashloader_erase_sectors(g_cfg
[g_curr_buf
].dest
,
151 g_cfg
[g_curr_buf
].len
);
154 status
= STATUS_FAILED_UNKNOWN_COMMAND
;
158 restore_cache_state();
160 /* Enter infinite loop on error condition */
161 if (status
!= STATUS_OK
) {
162 g_cfg
[g_curr_buf
].full
= status
;
167 /* Mark current task complete, and begin looking at next buffer */
168 g_cfg
[g_curr_buf
].full
= BUFFER_EMPTY
;
173 void _exit(int status
)
175 /* Enter infinite loop on hitting an exit condition */
176 (void)status
; /* Unused parameter */
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)