commit d5740e03eb1a5603caa941012b1e3b80fb3f13e0
parent 1ed3027cb83464ccae6c05cc4e8343dfc458e7c2
Author: Brian Swetland <swetland@playground.global>
Date: Thu, 14 Jan 2016 19:15:00 -0800
initial cc13xx agent for ti cc13xx and cc26xx devices
Diffstat:
3 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -43,6 +43,7 @@ $(call agent, lpclink2, 0x10080400)
$(call agent, stm32f4xx, 0x20000400)
$(call agent, lpc13xx, 0x10000400)
$(call agent, lpc15xx, 0x02000400)
+$(call agent, cc13xx, 0x20000400)
# tool to pack the agents into a source file
SRCS := tools/mkbuiltins.c
diff --git a/agents/cc13xx-romapi.h b/agents/cc13xx-romapi.h
@@ -0,0 +1,35 @@
+
+#define ROM_API_TABLE ((u32*) 0x10000180)
+#define ROM_API_FLASH_TABLE ((u32*) (ROM_API_TABLE[10]))
+
+#define ROM_FlashPowerModeGet \
+ ((u32 (*)(void)) \
+ ROM_API_FLASH_TABLE[1])
+
+#define ROM_FlashProtectionSet \
+ ((void (*)(u32 ui32SectorAddress, u32 ui32ProtectMode)) \
+ ROM_API_FLASH_TABLE[2])
+
+#define ROM_FlashProtectionGet \
+ ((u32 (*)(u32 ui32SectorAddress)) \
+ ROM_API_FLASH_TABLE[3])
+
+#define ROM_FlashProtectionSave \
+ ((u32 (*)(u32 ui32SectorAddress)) \
+ ROM_API_FLASH_TABLE[4])
+
+#define ROM_FlashSectorErase \
+ ((u32 (*)(u32 ui32SectorAddress)) \
+ ROM_API_FLASH_TABLE[5])
+
+#define ROM_FlashProgram \
+ ((u32 (*)(const void *pui8DataBuffer, u32 ui32Address, u32 ui32Count)) \
+ ROM_API_FLASH_TABLE[6])
+
+#define ROM_FlashEfuseReadRow \
+ ((u32 (*)(u32* pui32EfuseData, u32 ui32RowAddress)) \
+ ROM_API_FLASH_TABLE[8])
+
+#define ROM_FlashDisableSectorsForWrite \
+ ((void (*)(void)) \
+ ROM_API_FLASH_TABLE[9])
diff --git a/agents/cc13xx.c b/agents/cc13xx.c
@@ -0,0 +1,70 @@
+// agent-lpc15xx/main.c
+//
+// Copyright 2016 Brian Swetland <swetland@frotz.net>
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <agent/flash.h>
+#include "cc13xx-romapi.h"
+
+int flash_agent_setup(flash_agent *agent) {
+ return ERR_NONE;
+}
+
+int flash_agent_erase(u32 flash_addr, u32 length) {
+ if (flash_addr & 0xFFF) {
+ return ERR_ALIGNMENT;
+ }
+ while (length > 0) {
+ if (ROM_FlashSectorErase(flash_addr)) {
+ return ERR_FAIL;
+ }
+ if (length > 4096) {
+ length -= 4096;
+ flash_addr += 4096;
+ } else {
+ break;
+ }
+ }
+ return 0;
+}
+
+int flash_agent_write(u32 flash_addr, const void *data, u32 length) {
+ if (flash_addr & 0xFFF) {
+ return ERR_ALIGNMENT;
+ }
+ if (ROM_FlashProgram(data, flash_addr, length)) {
+ return ERR_FAIL;
+ }
+ return 0;
+}
+
+
+int flash_agent_ioctl(u32 op, void *ptr, u32 arg0, u32 arg1) {
+ return ERR_INVALID;
+}
+
+const flash_agent __attribute((section(".vectors"))) FlashAgent = {
+ .magic = AGENT_MAGIC,
+ .version = AGENT_VERSION,
+ .flags = 0,
+ .load_addr = 0x20000400,
+ .data_addr = 0x20001000,
+ .data_size = 0x1000,
+ .flash_addr = 0x00000000,
+ .flash_size = 0x00020000,
+ .setup = flash_agent_setup,
+ .erase = flash_agent_erase,
+ .write = flash_agent_write,
+ .ioctl = flash_agent_ioctl,
+};