Skip to content

Commit 6b5b1ed

Browse files
committed
Added support for Texas Instrument cc26x2
1 parent e4f0b8d commit 6b5b1ed

3 files changed

Lines changed: 168 additions & 1 deletion

File tree

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ OBJS:= \
3333
./lib/wolfssl/wolfcrypt/src/wolfmath.o \
3434
./lib/wolfssl/wolfcrypt/src/fe_low_mem.o
3535

36+
## Target specific configuration
3637

3738
ifeq ($(TARGET),samr21)
3839
CORTEX_M0=1
3940
endif
4041

42+
43+
44+
## Signature
45+
4146
ifeq ($(SIGN),ECC256)
4247
KEYGEN_TOOL=tools/ecc256/ecc256_keygen
4348
SIGN_TOOL=tools/ecc256/ecc256_sign
@@ -117,7 +122,6 @@ ifeq ($(VTOR),0)
117122
endif
118123

119124
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles -mcpu=cortex-m3 -mthumb
120-
121125
ASFLAGS:=$(CFLAGS)
122126

123127
all: factory.bin

hal/cc26x2.c

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/* cc26x2.c
2+
*
3+
* Copyright (C) 2018 wolfSSL Inc.
4+
*
5+
* This file is part of wolfBoot.
6+
*
7+
* wolfBoot is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfBoot is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
#include <stdint.h>
23+
24+
#include "oscillators.h"
25+
#include "ti-lib.h"
26+
27+
#include "target.h" /* For WOLFBOOT_SECTOR_SIZE */
28+
extern void clock_init(void);
29+
30+
char uart_read(void)
31+
{
32+
return (char)UARTCharGet(UART0_BASE);
33+
}
34+
35+
int uart_read_nonblock(char *c)
36+
{
37+
int ret = UARTCharGetNonBlocking(UART0_BASE);
38+
if (ret == -1)
39+
return 0;
40+
*c = (char)ret;
41+
return 1;
42+
}
43+
44+
45+
int hal_flash_write(uint32_t address, const uint8_t *data, int len)
46+
{
47+
FlashProgram(data, address, len);
48+
while(FlashCheckFsmForReady() != FAPI_STATUS_FSM_READY)
49+
;
50+
return 0;
51+
}
52+
53+
void hal_flash_unlock(void)
54+
{
55+
}
56+
57+
void hal_flash_lock(void)
58+
{
59+
}
60+
61+
62+
int hal_flash_erase(uint32_t address, int len)
63+
{
64+
int i = 0;
65+
while (len > 0) {
66+
FlashSectorErase(address + (WOLFBOOT_SECTOR_SIZE * i++));
67+
while(FlashCheckFsmForReady() != FAPI_STATUS_FSM_READY)
68+
;
69+
70+
if (len <= WOLFBOOT_SECTOR_SIZE)
71+
break;
72+
len -= WOLFBOOT_SECTOR_SIZE;
73+
}
74+
return 0;
75+
}
76+
77+
void hal_init(void)
78+
{
79+
/* Enable flash cache and prefetch. */
80+
ti_lib_vims_mode_set(VIMS_BASE, VIMS_MODE_ENABLED);
81+
ti_lib_vims_configure(VIMS_BASE, true, true);
82+
83+
ti_lib_int_master_disable();
84+
85+
ti_lib_prcm_power_domain_on(PRCM_DOMAIN_PERIPH);
86+
while((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH)
87+
!= PRCM_DOMAIN_POWER_ON))
88+
;
89+
90+
ti_lib_prcm_power_domain_on(PRCM_DOMAIN_SERIAL);
91+
while ((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_SERIAL)) != PRCM_DOMAIN_POWER_ON)
92+
;
93+
94+
ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_GPIO);
95+
ti_lib_prcm_load_set();
96+
while(!ti_lib_prcm_load_get())
97+
;
98+
ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_UART0);
99+
100+
ti_lib_prcm_load_set();
101+
while(!ti_lib_prcm_load_get())
102+
;
103+
104+
ti_lib_int_master_enable();
105+
106+
clock_init();
107+
}
108+
109+
void hal_prepare_boot(void)
110+
{
111+
}
112+

hal/cc26x2.ld

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x0010000
4+
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0xD800
5+
}
6+
7+
SECTIONS
8+
{
9+
.text :
10+
{
11+
_start_text = .;
12+
KEEP(*(.isr_vector))
13+
*(.text*)
14+
*(.rodata*)
15+
*(.init*)
16+
*(.fini*)
17+
. = ALIGN(4);
18+
_end_text = .;
19+
} > FLASH
20+
21+
.edidx :
22+
{
23+
. = ALIGN(4);
24+
*(.ARM.exidx*)
25+
} > FLASH
26+
27+
_stored_data = .;
28+
29+
.data : AT (_stored_data)
30+
{
31+
_start_data = .;
32+
KEEP(*(.data*))
33+
. = ALIGN(4);
34+
_end_data = .;
35+
} > RAM
36+
37+
.bss (NOLOAD) :
38+
{
39+
_start_bss = .;
40+
__bss_start__ = .;
41+
*(.bss*)
42+
*(COMMON)
43+
. = ALIGN(4);
44+
_end_bss = .;
45+
__bss_end__ = .;
46+
_end = .;
47+
} > RAM
48+
. = ALIGN(4);
49+
}
50+
51+
END_STACK = ORIGIN(RAM) + LENGTH(RAM);

0 commit comments

Comments
 (0)