aboutsummaryrefslogtreecommitdiff
path: root/cc3200/bootmgr
diff options
context:
space:
mode:
authorDamien George2017-09-06 13:40:51 +1000
committerDamien George2017-09-06 13:40:51 +1000
commit01dd7804b87d60b2deab16712eccb3b97351a9b7 (patch)
tree1aa21f38a872b8e62a3d4e4f74f68033c6f827e4 /cc3200/bootmgr
parenta9862b30068fc9df1022f08019fb35aaa5085f64 (diff)
ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is core and what is a port, and to allow the repository to grow with new ports in a sustainable way.
Diffstat (limited to 'cc3200/bootmgr')
-rw-r--r--cc3200/bootmgr/bootgen.sh50
-rw-r--r--cc3200/bootmgr/bootloader.mk132
-rw-r--r--cc3200/bootmgr/bootmgr.h68
-rw-r--r--cc3200/bootmgr/bootmgr.lds82
-rw-r--r--cc3200/bootmgr/flc.h95
-rw-r--r--cc3200/bootmgr/main.c419
-rw-r--r--cc3200/bootmgr/relocator/relocator.binbin184 -> 0 bytes
-rw-r--r--cc3200/bootmgr/runapp.s19
-rw-r--r--cc3200/bootmgr/sl/user.h1063
9 files changed, 0 insertions, 1928 deletions
diff --git a/cc3200/bootmgr/bootgen.sh b/cc3200/bootmgr/bootgen.sh
deleted file mode 100644
index f4bf32540..000000000
--- a/cc3200/bootmgr/bootgen.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-
-if [ "$#" -ne 1 ]; then
- echo "Usage: bootgen.sh *build dir*"
- exit 1
-fi
-
-BUILD=$1
-
-# Re-locator Path
-RELOCATOR=bootmgr/relocator
-
-# Build location
-BOOTMGR=${BUILD}
-
-# Check for re-locator binary
-if [ ! -f $RELOCATOR/relocator.bin ]; then
-
- echo "Error : Relocator Not found!"
- exit 1
-else
- echo "Relocator found..."
-fi
-
-# Check for boot manager binary
-if [ ! -f $BOOTMGR/bootmgr.bin ]; then
-
- echo "Error : Boot Manager Not found!"
- exit 1
-else
- echo "Boot Manager found..."
-fi
-
-# echo
-echo "Generating bootloader..."
-
-# Generate an all 0 bin file
-dd if=/dev/zero of=__tmp.bin ibs=1 count=256 conv=notrunc >/dev/null 2>&1
-
-# Generate a 0 padded version of the relocator
-dd if=$RELOCATOR/relocator.bin of=__tmp.bin ibs=1 conv=notrunc >/dev/null 2>&1
-
-# Concatenate the re-locator and the boot-manager
-cat __tmp.bin $BOOTMGR/bootmgr.bin > $BOOTMGR/bootloader.bin
-
-# Remove the tmp files
-rm -f __tmp.bin
-
-# Remove bootmgr.bin
-rm -f $BOOTMGR/bootmgr.bin
diff --git a/cc3200/bootmgr/bootloader.mk b/cc3200/bootmgr/bootloader.mk
deleted file mode 100644
index b8aa9082c..000000000
--- a/cc3200/bootmgr/bootloader.mk
+++ /dev/null
@@ -1,132 +0,0 @@
-BUILD = bootmgr/build/$(BOARD)/$(BTYPE)
-
-BOOT_INC = -Ibootmgr
-BOOT_INC += -Ibootmgr/sl
-BOOT_INC += -Ihal
-BOOT_INC += -Ihal/inc
-BOOT_INC += -I$(TOP)/drivers/cc3100/inc
-BOOT_INC += -Imisc
-BOOT_INC += -Imods
-BOOT_INC += -Isimplelink
-BOOT_INC += -Isimplelink/oslib
-BOOT_INC += -Iutil
-BOOT_INC += -I$(TOP)
-BOOT_INC += -I.
-BOOT_INC += -I$(BUILD)
-
-BOOT_CPPDEFINES = -Dgcc -DBOOTLOADER -DTARGET_IS_CC3200 -DSL_TINY
-
-BOOT_HAL_SRC_C = $(addprefix hal/,\
- cpu.c \
- interrupt.c \
- gpio.c \
- pin.c \
- prcm.c \
- shamd5.c \
- spi.c \
- startup_gcc.c \
- systick.c \
- utils.c \
- )
-
-BOOT_CC3100_SRC_C = $(addprefix drivers/cc3100/,\
- src/device.c \
- src/driver.c \
- src/flowcont.c \
- src/fs.c \
- src/netapp.c \
- src/netcfg.c \
- src/nonos.c \
- src/socket.c \
- src/spawn.c \
- src/wlan.c \
- )
-
-BOOT_MISC_SRC_C = $(addprefix misc/,\
- antenna.c \
- mperror.c \
- )
-
-BOOT_SL_SRC_C = $(addprefix simplelink/,\
- cc_pal.c \
- )
-
-BOOT_UTIL_SRC_C = $(addprefix util/,\
- cryptohash.c \
- )
-
-BOOT_MAIN_SRC_C = \
- bootmgr/main.c
-
-BOOT_MAIN_SRC_S = \
- bootmgr/runapp.s
-
-BOOT_PY_SRC_C = $(addprefix py/,\
- mpprint.c \
- )
-
-BOOT_LIB_SRC_C = $(addprefix lib/,\
- libc/string0.c \
- utils/printf.c \
- )
-
-OBJ = $(addprefix $(BUILD)/, $(BOOT_HAL_SRC_C:.c=.o) $(BOOT_SL_SRC_C:.c=.o) $(BOOT_CC3100_SRC_C:.c=.o) $(BOOT_UTIL_SRC_C:.c=.o) $(BOOT_MISC_SRC_C:.c=.o))
-OBJ += $(addprefix $(BUILD)/, $(BOOT_MAIN_SRC_C:.c=.o) $(BOOT_MAIN_SRC_S:.s=.o) $(BOOT_PY_SRC_C:.c=.o))
-OBJ += $(addprefix $(BUILD)/, $(BOOT_LIB_SRC_C:.c=.o))
-
-# Add the linker script
-LINKER_SCRIPT = bootmgr/bootmgr.lds
-LDFLAGS += -T $(LINKER_SCRIPT)
-
-# Add the bootloader specific CFLAGS
-CFLAGS += $(BOOT_CPPDEFINES) $(BOOT_INC)
-
-# Disable strict aliasing for the simplelink driver
-$(BUILD)/drivers/cc3100/src/driver.o: CFLAGS += -fno-strict-aliasing
-
-# Check if we would like to debug the port code
-ifeq ($(BTYPE), release)
-# Optimize everything and define the NDEBUG flag
-CFLAGS += -Os -DNDEBUG
-else
-ifeq ($(BTYPE), debug)
-# Define the DEBUG flag
-CFLAGS += -DDEBUG=DEBUG
-# Optimize the stable sources only
-$(BUILD)/hal/%.o: CFLAGS += -Os
-$(BUILD)/misc/%.o: CFLAGS += -Os
-$(BUILD)/simplelink/%.o: CFLAGS += -Os
-$(BUILD)/drivers/cc3100/%.o: CFLAGS += -Os
-$(BUILD)/py/%.o: CFLAGS += -Os
-$(BUILD)/stmhal/%.o: CFLAGS += -Os
-else
-$(error Invalid BTYPE specified)
-endif
-endif
-
-SHELL = bash
-BOOT_GEN = bootmgr/bootgen.sh
-HEADER_BUILD = $(BUILD)/genhdr
-
-all: $(BUILD)/bootloader.bin
-
-$(BUILD)/bootmgr.axf: $(OBJ) $(LINKER_SCRIPT)
- $(ECHO) "LINK $@"
- $(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
- $(Q)$(SIZE) $@
-
-$(BUILD)/bootmgr.bin: $(BUILD)/bootmgr.axf
- $(ECHO) "Create $@"
- $(Q)$(OBJCOPY) -O binary $< $@
-
-$(BUILD)/bootloader.bin: $(BUILD)/bootmgr.bin
- $(ECHO) "Create $@"
- $(Q)$(SHELL) $(BOOT_GEN) $(BUILD)
-
-# Create an empty "qstrdefs.generated.h" needed by py/mkrules.mk
-$(HEADER_BUILD)/qstrdefs.generated.h: | $(HEADER_BUILD)
- touch $@
-
-# Create an empty "mpversion.h" needed by py/mkrules.mk
-$(HEADER_BUILD)/mpversion.h: | $(HEADER_BUILD)
- touch $@
diff --git a/cc3200/bootmgr/bootmgr.h b/cc3200/bootmgr/bootmgr.h
deleted file mode 100644
index 5a370f8c9..000000000
--- a/cc3200/bootmgr/bootmgr.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2015 Daniel Campora
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#ifndef MICROPY_INCLUDED_CC3200_BOOTMGR_BOOTMGR_H
-#define MICROPY_INCLUDED_CC3200_BOOTMGR_BOOTMGR_H
-
-//****************************************************************************
-//
-// If building with a C++ compiler, make all of the definitions in this header
-// have a C binding.
-//
-//****************************************************************************
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-//*****************************************************************************
-// User image tokens
-//*****************************************************************************
-#define FACTORY_IMG_TOKEN 0x5555AAAA
-#define UPDATE_IMG_TOKEN 0xAA5555AA
-#define USER_BOOT_INFO_TOKEN 0xA5A55A5A
-
-//*****************************************************************************
-// Macros
-//*****************************************************************************
-#define APP_IMG_SRAM_OFFSET 0x20004000
-#define DEVICE_IS_CC3101RS 0x18
-#define DEVICE_IS_CC3101S 0x1B
-
-//*****************************************************************************
-// Function prototype
-//*****************************************************************************
-extern void Run(unsigned long);
-
-//****************************************************************************
-//
-// Mark the end of the C bindings section for C++ compilers.
-//
-//****************************************************************************
-#ifdef __cplusplus
-}
-#endif
-
-#endif // MICROPY_INCLUDED_CC3200_BOOTMGR_BOOTMGR_H
diff --git a/cc3200/bootmgr/bootmgr.lds b/cc3200/bootmgr/bootmgr.lds
deleted file mode 100644
index 9c911a0d0..000000000
--- a/cc3200/bootmgr/bootmgr.lds
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2015 Daniel Campora
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-__stack_size__ = 1024;
-
-MEMORY
-{
- SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00004000
-}
-
-ENTRY(ResetISR)
-
-SECTIONS
-{
- .text :
- {
- _text = .;
- KEEP(*(.intvecs))
- *(.boot*)
- *(.text*)
- *(.rodata*)
- *(.ARM.extab* .gnu.linkonce.armextab.*)
- . = ALIGN(8);
- } > SRAM
-
- .ARM :
- {
- __exidx_start = .;
- *(.ARM.exidx*)
- __exidx_end = .;
- _etext = .;
- } > SRAM
-
- .data :
- {
- _data = .;
- *(.data*)
- . = ALIGN (8);
- _edata = .;
- } > SRAM
-
- .bss :
- {
- _bss = .;
- *(.bss*)
- *(COMMON)
- _ebss = .;
- } > SRAM
-
- .stack ORIGIN(SRAM) + LENGTH(SRAM) - __stack_size__ :
- {
- . = ALIGN(8);
- _stack = .;
- . = . + __stack_size__;
- . = ALIGN(8);
- _estack = .;
- } > SRAM
-}
-
diff --git a/cc3200/bootmgr/flc.h b/cc3200/bootmgr/flc.h
deleted file mode 100644
index 8f05bb320..000000000
--- a/cc3200/bootmgr/flc.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2015 Daniel Campora
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#ifndef MICROPY_INCLUDED_CC3200_BOOTMGR_FLC_H
-#define MICROPY_INCLUDED_CC3200_BOOTMGR_FLC_H
-
-/******************************************************************************
-
- If building with a C++ compiler, make all of the definitions in this header
- have a C binding.
-
-*******************************************************************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/******************************************************************************
- Image file names
-*******************************************************************************/
-#define IMG_BOOT_INFO "/sys/bootinfo.bin"
-#define IMG_FACTORY "/sys/factimg.bin"
-#define IMG_UPDATE1 "/sys/updtimg1.bin"
-#define IMG_UPDATE2 "/sys/updtimg2.bin"
-#define IMG_PREFIX "/sys/updtimg"
-
-#define IMG_SRVPACK "/sys/servicepack.ucf"
-#define SRVPACK_SIGN "/sys/servicepack.sig"
-
-#define CA_FILE "/cert/ca.pem"
-#define CERT_FILE "/cert/cert.pem"
-#define KEY_FILE "/cert/private.key"
-
-/******************************************************************************
- Special file sizes
-*******************************************************************************/
-#define IMG_SIZE (192 * 1024) /* 16KB are reserved for the bootloader and at least 48KB for the heap*/
-#define SRVPACK_SIZE (16 * 1024)
-#define SIGN_SIZE (2 * 1024)
-#define CA_KEY_SIZE (4 * 1024)
-
-/******************************************************************************
- Active Image
-*******************************************************************************/
-#define IMG_ACT_FACTORY 0
-#define IMG_ACT_UPDATE1 1
-#define IMG_ACT_UPDATE2 2
-
-#define IMG_STATUS_CHECK 0
-#define IMG_STATUS_READY 1
-
-/******************************************************************************
- Boot Info structure
-*******************************************************************************/
-typedef struct _sBootInfo_t
-{
- _u8 ActiveImg;
- _u8 Status;
- _u8 PrevImg;
- _u8 : 8;
-} sBootInfo_t;
-
-
-/******************************************************************************
-
- Mark the end of the C bindings section for C++ compilers.
-
-*******************************************************************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif // MICROPY_INCLUDED_CC3200_BOOTMGR_FLC_H
diff --git a/cc3200/bootmgr/main.c b/cc3200/bootmgr/main.c
deleted file mode 100644
index cfb8dec21..000000000
--- a/cc3200/bootmgr/main.c
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2015 Daniel Campora
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdio.h>
-
-#include "py/mpconfig.h"
-#include "hw_ints.h"
-#include "hw_types.h"
-#include "hw_gpio.h"
-#include "hw_memmap.h"
-#include "hw_gprcm.h"
-#include "hw_common_reg.h"
-#include "pin.h"
-#include "gpio.h"
-#include "rom_map.h"
-#include "prcm.h"
-#include "simplelink.h"
-#include "interrupt.h"
-#include "gpio.h"
-#include "flc.h"
-#include "bootmgr.h"
-#include "shamd5.h"
-#include "cryptohash.h"
-#include "utils.h"
-#include "cc3200_hal.h"
-#include "debug.h"
-#include "mperror.h"
-#include "antenna.h"
-
-
-//*****************************************************************************
-// Local Constants
-//*****************************************************************************
-#define SL_STOP_TIMEOUT 35
-#define BOOTMGR_HASH_ALGO SHAMD5_ALGO_MD5
-#define BOOTMGR_HASH_SIZE 32
-#define BOOTMGR_BUFF_SIZE 512
-
-#define BOOTMGR_WAIT_SAFE_MODE_0_MS 500
-
-#define BOOTMGR_WAIT_SAFE_MODE_1_MS 3000
-#define BOOTMGR_WAIT_SAFE_MODE_1_BLINK_MS 500
-
-#define BOOTMGR_WAIT_SAFE_MODE_2_MS 3000
-#define BOOTMGR_WAIT_SAFE_MODE_2_BLINK_MS 250
-
-#define BOOTMGR_WAIT_SAFE_MODE_3_MS 1500
-#define BOOTMGR_WAIT_SAFE_MODE_3_BLINK_MS 100
-
-//*****************************************************************************
-// Exported functions declarations
-//*****************************************************************************
-extern void bootmgr_run_app (_u32 base);
-
-//*****************************************************************************
-// Local functions declarations
-//*****************************************************************************
-static void bootmgr_board_init (void);
-static bool bootmgr_verify (_u8 *image);
-static void bootmgr_load_and_execute (_u8 *image);
-static bool wait_while_blinking (uint32_t wait_time, uint32_t period, bool force_wait);
-static bool safe_boot_request_start (uint32_t wait_time);
-static void wait_for_safe_boot (sBootInfo_t *psBootInfo);
-static void bootmgr_image_loader (sBootInfo_t *psBootInfo);
-
-//*****************************************************************************
-// Private data
-//*****************************************************************************
-static _u8 bootmgr_file_buf[BOOTMGR_BUFF_SIZE];
-static _u8 bootmgr_hash_buf[BOOTMGR_HASH_SIZE + 1];
-
-//*****************************************************************************
-// Vector Table
-//*****************************************************************************
-extern void (* const g_pfnVectors[])(void);
-
-//*****************************************************************************
-// WLAN Event handler callback hookup function
-//*****************************************************************************
-void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent)
-{
-
-}
-
-//*****************************************************************************
-// HTTP Server callback hookup function
-//*****************************************************************************
-void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pHttpEvent,
- SlHttpServerResponse_t *pHttpResponse)
-{
-
-}
-
-//*****************************************************************************
-// Net APP Event callback hookup function
-//*****************************************************************************
-void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
-{
-
-}
-
-//*****************************************************************************
-// General Event callback hookup function
-//*****************************************************************************
-void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *pDevEvent)
-{
-
-}
-
-//*****************************************************************************
-// Socket Event callback hookup function
-//*****************************************************************************
-void SimpleLinkSockEventHandler(SlSockEvent_t *pSock)
-{
-
-}
-
-//*****************************************************************************
-//! Board Initialization & Configuration
-//*****************************************************************************
-static void bootmgr_board_init(void) {
- // set the vector table base
- MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
-
- // enable processor interrupts
- MAP_IntMasterEnable();
- MAP_IntEnable(FAULT_SYSTICK);
-
- // mandatory MCU initialization
- PRCMCC3200MCUInit();
-
- // clear all the special bits, since we can't trust their content after reset
- // except for the WDT reset one!!
- PRCMClearSpecialBit(PRCM_SAFE_BOOT_BIT);
- PRCMClearSpecialBit(PRCM_FIRST_BOOT_BIT);
-
- // check the reset after clearing the special bits
- mperror_bootloader_check_reset_cause();
-
-#if MICROPY_HW_ANTENNA_DIVERSITY
- // configure the antenna selection pins
- antenna_init0();
-#endif
-
- // enable the data hashing engine
- CRYPTOHASH_Init();
-
- // init the system led and the system switch
- mperror_init0();
-}
-
-//*****************************************************************************
-//! Verifies the integrity of the new application binary
-//*****************************************************************************
-static bool bootmgr_verify (_u8 *image) {
- SlFsFileInfo_t FsFileInfo;
- _u32 reqlen, offset = 0;
- _i32 fHandle;
-
- // open the file for reading
- if (0 == sl_FsOpen(image, FS_MODE_OPEN_READ, NULL, &fHandle)) {
- // get the file size
- sl_FsGetInfo(image, 0, &FsFileInfo);
-
- if (FsFileInfo.FileLen > BOOTMGR_HASH_SIZE) {
- FsFileInfo.FileLen -= BOOTMGR_HASH_SIZE;
- CRYPTOHASH_SHAMD5Start(BOOTMGR_HASH_ALGO, FsFileInfo.FileLen);
- do {
- if ((FsFileInfo.FileLen - offset) > BOOTMGR_BUFF_SIZE) {
- reqlen = BOOTMGR_BUFF_SIZE;
- }
- else {
- reqlen = FsFileInfo.FileLen - offset;
- }
-
- offset += sl_FsRead(fHandle, offset, bootmgr_file_buf, reqlen);
- CRYPTOHASH_SHAMD5Update(bootmgr_file_buf, reqlen);
- } while (offset < FsFileInfo.FileLen);
-
- CRYPTOHASH_SHAMD5Read (bootmgr_file_buf);
-
- // convert the resulting hash to hex
- for (_u32 i = 0; i < (BOOTMGR_HASH_SIZE / 2); i++) {
- snprintf ((char *)&bootmgr_hash_buf[(i * 2)], 3, "%02x", bootmgr_file_buf[i]);
- }
-
- // read the hash from the file and close it
- sl_FsRead(fHandle, offset, bootmgr_file_buf, BOOTMGR_HASH_SIZE);
- sl_FsClose (fHandle, NULL, NULL, 0);
- bootmgr_file_buf[BOOTMGR_HASH_SIZE] = '\0';
- // compare both hashes
- if (!strcmp((const char *)bootmgr_hash_buf, (const char *)bootmgr_file_buf)) {
- // it's a match
- return true;
- }
- }
- // close the file
- sl_FsClose(fHandle, NULL, NULL, 0);
- }
- return false;
-}
-
-//*****************************************************************************
-//! Loads the application from sFlash and executes
-//*****************************************************************************
-static void bootmgr_load_and_execute (_u8 *image) {
- SlFsFileInfo_t pFsFileInfo;
- _i32 fhandle;
- // open the application binary
- if (!sl_FsOpen(image, FS_MODE_OPEN_READ, NULL, &fhandle)) {
- // get the file size
- if (!sl_FsGetInfo(image, 0, &pFsFileInfo)) {
- // read the application into SRAM
- if (pFsFileInfo.FileLen == sl_FsRead(fhandle, 0, (unsigned char *)APP_IMG_SRAM_OFFSET, pFsFileInfo.FileLen)) {
- // close the file
- sl_FsClose(fhandle, 0, 0, 0);
- // stop the network services
- sl_Stop(SL_STOP_TIMEOUT);
- // execute the application
- bootmgr_run_app(APP_IMG_SRAM_OFFSET);
- }
- }
- }
-}
-
-//*****************************************************************************
-//! Wait while the safe mode pin is being held high and blink the system led
-//! with the specified period
-//*****************************************************************************
-static bool wait_while_blinking (uint32_t wait_time, uint32_t period, bool force_wait) {
- _u32 count;
- for (count = 0; (force_wait || MAP_GPIOPinRead(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN)) &&
- ((period * count) < wait_time); count++) {
- // toogle the led
- MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, ~MAP_GPIOPinRead(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN));
- UtilsDelay(UTILS_DELAY_US_TO_COUNT(period * 1000));
- }
- return MAP_GPIOPinRead(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN) ? true : false;
-}
-
-static bool safe_boot_request_start (uint32_t wait_time) {
- if (MAP_GPIOPinRead(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN)) {
- UtilsDelay(UTILS_DELAY_US_TO_COUNT(wait_time * 1000));
- }
- return MAP_GPIOPinRead(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN) ? true : false;
-}
-
-//*****************************************************************************
-//! Check for the safe mode pin
-//*****************************************************************************
-static void wait_for_safe_boot (sBootInfo_t *psBootInfo) {
- if (safe_boot_request_start(BOOTMGR_WAIT_SAFE_MODE_0_MS)) {
- if (wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_1_MS, BOOTMGR_WAIT_SAFE_MODE_1_BLINK_MS, false)) {
- // go back one step in time
- psBootInfo->ActiveImg = psBootInfo->PrevImg;
- if (wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_2_MS, BOOTMGR_WAIT_SAFE_MODE_2_BLINK_MS, false)) {
- // go back directly to the factory image
- psBootInfo->ActiveImg = IMG_ACT_FACTORY;
- wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_3_MS, BOOTMGR_WAIT_SAFE_MODE_3_BLINK_MS, true);
- }
- }
- // turn off the system led
- MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
- // request a safe boot to the application
- PRCMSetSpecialBit(PRCM_SAFE_BOOT_BIT);
- }
- // deinit the safe boot pin
- mperror_deinit_sfe_pin();
-}
-
-//*****************************************************************************
-//! Load the proper image based on the information from the boot info
-//! and launch it.
-//*****************************************************************************
-static void bootmgr_image_loader(sBootInfo_t *psBootInfo) {
- _i32 fhandle;
- _u8 *image;
-
- // search for the active image
- switch (psBootInfo->ActiveImg) {
- case IMG_ACT_UPDATE1:
- image = (unsigned char *)IMG_UPDATE1;
- break;
- case IMG_ACT_UPDATE2:
- image = (unsigned char *)IMG_UPDATE2;
- break;
- default:
- image = (unsigned char *)IMG_FACTORY;
- break;
- }
-
- // do we have a new image that needs to be verified?
- if ((psBootInfo->ActiveImg != IMG_ACT_FACTORY) && (psBootInfo->Status == IMG_STATUS_CHECK)) {
- if (!bootmgr_verify(image)) {
- // verification failed, delete the broken file
- sl_FsDel(image, 0);
- // switch to the previous image
- psBootInfo->ActiveImg = psBootInfo->PrevImg;
- psBootInfo->PrevImg = IMG_ACT_FACTORY;
- }
- // in any case, change the status to "READY"
- psBootInfo->Status = IMG_STATUS_READY;
- // write the new boot info
- if (!sl_FsOpen((unsigned char *)IMG_BOOT_INFO, FS_MODE_OPEN_WRITE, NULL, &fhandle)) {
- sl_FsWrite(fhandle, 0, (unsigned char *)psBootInfo, sizeof(sBootInfo_t));
- // close the file
- sl_FsClose(fhandle, 0, 0, 0);
- }
- }
-
- // this one might modify the boot info hence it MUST be called after
- // bootmgr_verify! (so that the changes are not saved to flash)
- wait_for_safe_boot(psBootInfo);
-
- // select the active image again, since it might have changed
- switch (psBootInfo->ActiveImg) {
- case IMG_ACT_UPDATE1:
- image = (unsigned char *)IMG_UPDATE1;
- break;
- case IMG_ACT_UPDATE2:
- image = (unsigned char *)IMG_UPDATE2;
- break;
- default:
- image = (unsigned char *)IMG_FACTORY;
- break;
- }
- bootmgr_load_and_execute(image);
-}
-
-//*****************************************************************************
-//! Main function
-//*****************************************************************************
-int main (void) {
- sBootInfo_t sBootInfo = { .ActiveImg = IMG_ACT_FACTORY, .Status = IMG_STATUS_READY, .PrevImg = IMG_ACT_FACTORY };
- bool bootapp = false;
- _i32 fhandle;
-
- // board setup
- bootmgr_board_init();
-
- // start simplelink since we need it to access the sflash
- sl_Start(0, 0, 0);
-
- // if a boot info file is found, load it, else, create a new one with the default boot info
- if (!sl_FsOpen((unsigned char *)IMG_BOOT_INFO, FS_MODE_OPEN_READ, NULL, &fhandle)) {
- if (sizeof(sBootInfo_t) == sl_FsRead(fhandle, 0, (unsigned char *)&sBootInfo, sizeof(sBootInfo_t))) {
- bootapp = true;
- }
- sl_FsClose(fhandle, 0, 0, 0);
- }
- // boot info file not present, it means that this is the first boot after being programmed
- if (!bootapp) {
- // create a new boot info file
- _u32 BootInfoCreateFlag = _FS_FILE_OPEN_FLAG_COMMIT | _FS_FILE_PUBLIC_WRITE | _FS_FILE_PUBLIC_READ;
- if (!sl_FsOpen ((unsigned char *)IMG_BOOT_INFO, FS_MODE_OPEN_CREATE((2 * sizeof(sBootInfo_t)),
- BootInfoCreateFlag), NULL, &fhandle)) {
- // write the default boot info.
- if (sizeof(sBootInfo_t) == sl_FsWrite(fhandle, 0, (unsigned char *)&sBootInfo, sizeof(sBootInfo_t))) {
- bootapp = true;
- }
- sl_FsClose(fhandle, 0, 0, 0);
- }
- // signal the first boot to the application
- PRCMSetSpecialBit(PRCM_FIRST_BOOT_BIT);
- }
-
- if (bootapp) {
- // load and execute the image based on the boot info
- bootmgr_image_loader(&sBootInfo);
- }
-
- // stop simplelink
- sl_Stop(SL_STOP_TIMEOUT);
-
- // if we've reached this point, then it means that a fatal error has occurred and the
- // application could not be loaded, so, loop forever and signal the crash to the user
- while (true) {
- // keep the bld on
- MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN);
- __asm volatile(" dsb \n"
- " isb \n"
- " wfi \n");
- }
-}
-
-//*****************************************************************************
-//! The following stub function is needed to link mp_vprintf
-//*****************************************************************************
-#include "py/qstr.h"
-
-const byte *qstr_data(qstr q, size_t *len) {
- *len = 0;
- return NULL;
-}
diff --git a/cc3200/bootmgr/relocator/relocator.bin b/cc3200/bootmgr/relocator/relocator.bin
deleted file mode 100644
index b1ac51005..000000000
--- a/cc3200/bootmgr/relocator/relocator.bin
+++ /dev/null
Binary files differ
diff --git a/cc3200/bootmgr/runapp.s b/cc3200/bootmgr/runapp.s
deleted file mode 100644
index 45c6dcb19..000000000
--- a/cc3200/bootmgr/runapp.s
+++ /dev/null
@@ -1,19 +0,0 @@
- .syntax unified
- .cpu cortex-m4
- .thumb
- .text
- .align 2
-
-@ void bootmgr_run_app(_u32 base)
- .global bootmgr_run_app
- .thumb
- .thumb_func
- .type bootmgr_run_app, %function
-bootmgr_run_app:
- @ set the SP
- ldr sp, [r0]
- add r0, r0, #4
-
- @ jump to the entry code
- ldr r1, [r0]
- bx r1
diff --git a/cc3200/bootmgr/sl/user.h b/cc3200/bootmgr/sl/user.h
deleted file mode 100644
index be93029d1..000000000
--- a/cc3200/bootmgr/sl/user.h
+++ /dev/null
@@ -1,1063 +0,0 @@
-/*
- * user.h - CC31xx/CC32xx Host Driver Implementation
- *
- * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
- *
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
-*/
-
-
-
-#ifndef __USER_H__
-#define __USER_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-
-
-/*!
- ******************************************************************************
-
- \defgroup porting_user_include Porting - User Include Files
-
- This section IS NOT REQUIRED in case user provided primitives are handled
- in makefiles or project configurations (IDE)
-
- PORTING ACTION:
- - Include all required header files for the definition of:
- -# Transport layer library API (e.g. SPI, UART)
- -# OS primitives definitions (e.g. Task spawn, Semaphores)
- -# Memory management primitives (e.g. alloc, free)
-
- ******************************************************************************
- */
-
-#include <string.h>
-#include "cc_pal.h"
-
-/*!
- \def MAX_CONCURRENT_ACTIONS
-
- \brief Defines the maximum number of concurrent action in the system
- Min:1 , Max: 32
-
- Actions which has async events as return, can be
-
- \sa
-
- \note In case there are not enough resources for the actions needed in the system,
- error is received: POOL_IS_EMPTY
- one option is to increase MAX_CONCURRENT_ACTIONS
- (improves performance but results in memory consumption)
- Other option is to call the API later (decrease performance)
-
- \warning In case of setting to one, recommend to use non-blocking recv\recvfrom to allow
- multiple socket recv
-*/
-#define MAX_CONCURRENT_ACTIONS 10
-/*!
- \def CPU_FREQ_IN_MHZ
- \brief Defines CPU frequency for Host side, for better accuracy of busy loops, if any
- \sa
- \note
-
- \warning If not set the default CPU frequency is set to 200MHz
- This option will be deprecated in future release
-*/
-
-#define CPU_FREQ_IN_MHZ 80
-
-
-/*!
- ******************************************************************************
-
- \defgroup porting_capabilities Porting - Capabilities Set
-
- This section IS NOT REQUIRED in case one of the following pre defined
- capabilities set is in use:
- - SL_TINY
- - SL_SMALL
- - SL_FULL
-
- PORTING ACTION:
- - Define one of the pre-defined capabilities set or uncomment the
- relevant definitions below to select the required capabilities
-
- @{
-
- *******************************************************************************
-*/
-
-/*!
- \def SL_INC_ARG_CHECK
-
- \brief Defines whether the SimpleLink driver perform argument check
- or not
-
- When defined, the SimpleLink driver perform argument check on
- function call. Removing this define could reduce some code
- size and improve slightly the performances but may impact in
- unpredictable behavior in case of invalid arguments
-
- \sa
-
- \note belongs to \ref proting_sec
-
- \warning Removing argument check may cause unpredictable behavior in
- case of invalid arguments.
- In this case the user is responsible to argument validity
- (for example all handlers must not be NULL)
-*/
-#define SL_INC_ARG_CHECK
-
-
-/*!
- \def SL_INC_STD_BSD_API_NAMING
-
- \brief Defines whether SimpleLink driver should expose standard BSD
- APIs or not
-
- When defined, the SimpleLink driver in addtion to its alternative
- BSD APIs expose also standard BSD APIs.
- Stadrad BSD API includs the following functions:
- socket , close , accept , bind , listen , connect , select ,
- setsockopt , getsockopt , recv , recvfrom , write , send , sendto ,
- gethostbyname
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_STD_BSD_API_NAMING
-
-
-/*!
- \brief Defines whether to include extended API in SimpleLink driver
- or not
-
- When defined, the SimpleLink driver will include also all
- exteded API of the included packages
-
- \sa ext_api
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_EXT_API
-
-/*!
- \brief Defines whether to include WLAN package in SimpleLink driver
- or not
-
- When defined, the SimpleLink driver will include also
- the WLAN package
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_WLAN_PKG
-
-/*!
- \brief Defines whether to include SOCKET package in SimpleLink
- driver or not
-
- When defined, the SimpleLink driver will include also
- the SOCKET package
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_SOCKET_PKG
-
-/*!
- \brief Defines whether to include NET_APP package in SimpleLink
- driver or not
-
- When defined, the SimpleLink driver will include also the
- NET_APP package
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_NET_APP_PKG
-
-/*!
- \brief Defines whether to include NET_CFG package in SimpleLink
- driver or not
-
- When defined, the SimpleLink driver will include also
- the NET_CFG package
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_NET_CFG_PKG
-
-/*!
- \brief Defines whether to include NVMEM package in SimpleLink
- driver or not
-
- When defined, the SimpleLink driver will include also the
- NVMEM package
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_NVMEM_PKG
-
-/*!
- \brief Defines whether to include socket server side APIs
- in SimpleLink driver or not
-
- When defined, the SimpleLink driver will include also socket
- server side APIs
-
- \sa server_side
-
- \note
-
- \warning
-*/
-#define SL_INC_SOCK_SERVER_SIDE_API
-
-/*!
- \brief Defines whether to include socket client side APIs in SimpleLink
- driver or not
-
- When defined, the SimpleLink driver will include also socket
- client side APIs
-
- \sa client_side
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_SOCK_CLIENT_SIDE_API
-
-/*!
- \brief Defines whether to include socket receive APIs in SimpleLink
- driver or not
-
- When defined, the SimpleLink driver will include also socket
- receive side APIs
-
- \sa recv_api
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_SOCK_RECV_API
-
-/*!
- \brief Defines whether to include socket send APIs in SimpleLink
- driver or not
-
- When defined, the SimpleLink driver will include also socket
- send side APIs
-
- \sa send_api
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-#define SL_INC_SOCK_SEND_API
-
-/*!
-
- Close the Doxygen group.
- @}
-
- */
-
-
-/*!
- ******************************************************************************
-
- \defgroup ported_enable_device Ported on CC32XX - Device Enable/Disable
-
- The enable/disable API provide mechanism to enable/disable the network processor
-
-
- PORTING ACTION:
- - None
- @{
-
- ******************************************************************************
- */
-
-/*!
- \brief Preamble to the enabling the Network Processor.
- Placeholder to implement any pre-process operations
- before enabling networking operations.
-
- \sa sl_DeviceEnable
-
- \note belongs to \ref ported_sec
-
-*/
-#ifdef DEBUG
-#define sl_DeviceEnablePreamble() NwpPowerOnPreamble()
-#else
-#define sl_DeviceEnablePreamble()
-#endif
-
-/*!
- \brief Enable the Network Processor
-
- \sa sl_DeviceDisable
-
- \note belongs to \ref ported_sec
-
-*/
-#define sl_DeviceEnable() NwpPowerOn()
-
-/*!
- \brief Disable the Network Processor
-
- \sa sl_DeviceEnable
-
- \note belongs to \ref ported_sec
-*/
-#define sl_DeviceDisable() NwpPowerOff()
-
-/*!
-
- Close the Doxygen group.
- @}
-
- */
-
-/*!
- ******************************************************************************
-
- \defgroup ported_interface Ported on CC32XX - Communication Interface
-
- The simple link device can work with different communication
- channels (e.g. spi/uart). Texas Instruments provides single driver
- that can work with all these types. This section bind between the
- physical communication interface channel and the SimpleLink driver
-
-
- \note Correct and efficient implementation of this driver is critical
- for the performances of the SimpleLink device on this platform.
-
-
- PORTING ACTION:
- - None
-
- @{
-
- ******************************************************************************
-*/
-
-#define _SlFd_t Fd_t
-
-/*!
- \brief Opens an interface communication port to be used for communicating
- with a SimpleLink device
-
- Given an interface name and option flags, this function opens
- the communication port and creates a file descriptor.
- This file descriptor is used afterwards to read and write
- data from and to this specific communication channel.
- The speed, clock polarity, clock phase, chip select and all other
- specific attributes of the channel are all should be set to hardcoded
- in this function.
-
- \param ifName - points to the interface name/path. The interface name is an
- optional attributes that the simple link driver receives
- on opening the driver (sl_Start).
- In systems that the spi channel is not implemented as
- part of the os device drivers, this parameter could be NULL.
-
- \param flags - optional flags parameters for future use
-
- \return upon successful completion, the function shall open the channel
- and return a non-negative integer representing the file descriptor.
- Otherwise, -1 shall be returned
-
- \sa sl_IfClose , sl_IfRead , sl_IfWrite
-
- \note The prototype of the function is as follow:
- Fd_t xxx_IfOpen(char* pIfName , unsigned long flags);
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-#define sl_IfOpen spi_Open
-
-/*!
- \brief Closes an opened interface communication port
-
- \param fd - file descriptor of opened communication channel
-
- \return upon successful completion, the function shall return 0.
- Otherwise, -1 shall be returned
-
- \sa sl_IfOpen , sl_IfRead , sl_IfWrite
-
- \note The prototype of the function is as follow:
- int xxx_IfClose(Fd_t Fd);
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-#define sl_IfClose spi_Close
-
-/*!
- \brief Attempts to read up to len bytes from an opened communication channel
- into a buffer starting at pBuff.
-
- \param fd - file descriptor of an opened communication channel
-
- \param pBuff - pointer to the first location of a buffer that contains enough
- space for all expected data
-
- \param len - number of bytes to read from the communication channel
-
- \return upon successful completion, the function shall return the number of read bytes.
- Otherwise, 0 shall be returned
-
- \sa sl_IfClose , sl_IfOpen , sl_IfWrite
-
-
- \note The prototype of the function is as follow:
- int xxx_IfRead(Fd_t Fd , char* pBuff , int Len);
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-#define sl_IfRead spi_Read
-
-/*!
- \brief attempts to write up to len bytes to the SPI channel
-
- \param fd - file descriptor of an opened communication channel
-
- \param pBuff - pointer to the first location of a buffer that contains
- the data to send over the communication channel
-
- \param len - number of bytes to write to the communication channel
-
- \return upon successful completion, the function shall return the number of sent bytes.
- therwise, 0 shall be returned
-
- \sa sl_IfClose , sl_IfOpen , sl_IfRead
-
- \note This function could be implemented as zero copy and return only upon successful completion
- of writing the whole buffer, but in cases that memory allocation is not too tight, the
- function could copy the data to internal buffer, return back and complete the write in
- parallel to other activities as long as the other SPI activities would be blocked until
- the entire buffer write would be completed
-
- The prototype of the function is as follow:
- int xxx_IfWrite(Fd_t Fd , char* pBuff , int Len);
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-#define sl_IfWrite spi_Write
-
-/*!
- \brief register an interrupt handler routine for the host IRQ
-
- \param InterruptHdl - pointer to interrupt handler routine
-
- \param pValue - pointer to a memory structure that is passed
- to the interrupt handler.
-
- \return upon successful registration, the function shall return 0.
- Otherwise, -1 shall be returned
-
- \sa
-
- \note If there is already registered interrupt handler, the function
- should overwrite the old handler with the new one
-
- \note If the handler is a null pointer, the function should un-register the
- interrupt handler, and the interrupts can be disabled.
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-#define sl_IfRegIntHdlr(InterruptHdl , pValue) NwpRegisterInterruptHandler(InterruptHdl , pValue)
-
-/*!
- \brief Masks the Host IRQ
-
- \sa sl_IfUnMaskIntHdlr
-
-
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-
-
-#define sl_IfMaskIntHdlr() NwpMaskInterrupt()
-
-/*!
- \brief Unmasks the Host IRQ
-
- \sa sl_IfMaskIntHdlr
-
-
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-
-#define sl_IfUnMaskIntHdlr() NwpUnMaskInterrupt()
-
-/*!
- \brief Write Handers for statistics debug on write
-
- \param interface handler - pointer to interrupt handler routine
-
-
- \return no return value
-
- \sa
-
- \note An optional hooks for monitoring before and after write info
-
- \note belongs to \ref ported_sec
-
- \warning
-*/
-/* #define SL_START_WRITE_STAT */
-
-
-/*!
-
- Close the Doxygen group.
- @}
-
-*/
-
-/*!
- ******************************************************************************
-
- \defgroup ported_os Ported on CC32XX - Operating System
-
- The simple link driver can run on multi-threaded environment as well
- as non-os environment (mail loop)
-
- This section IS NOT REQUIRED in case you are working on non-os environment.
-
- If you choose to work in multi-threaded environment under any operating system
- you will have to provide some basic adaptation routines to allow the driver
- to protect access to resources from different threads (locking object) and
- to allow synchronization between threads (sync objects).
-
- PORTING ACTION:
- -# Uncomment SL_PLATFORM_MULTI_THREADED define
- -# Bind locking object routines
- -# Bind synchronization object routines
- -# Optional - Bind spawn thread routine
-
- @{
-
- ******************************************************************************
-*/
-
-/*
-#define SL_PLATFORM_MULTI_THREADED
-*/
-
-#ifdef SL_PLATFORM_MULTI_THREADED
-#include "osi.h"
-
-
-/*!
- \brief
- \sa
- \note belongs to \ref ported_sec
- \warning
-*/
-#define SL_OS_RET_CODE_OK ((int)OSI_OK)
-
-/*!
- \brief
- \sa
- \note belongs to \ref ported_sec
- \warning
-*/
-#define SL_OS_WAIT_FOREVER ((OsiTime_t)OSI_WAIT_FOREVER)
-
-/*!
- \brief
- \sa
- \note belongs to \ref ported_sec
- \warning
-*/
-#define SL_OS_NO_WAIT ((OsiTime_t)OSI_NO_WAIT)
-
-/*!
- \brief type definition for a time value
-
- \note On each porting or platform the type could be whatever is needed - integer, pointer to structure etc.
-
- \note belongs to \ref ported_sec
-*/
-#define _SlTime_t OsiTime_t
-
-/*!
- \brief type definition for a sync object container
-
- Sync object is object used to synchronize between two threads or thread and interrupt handler.
- One thread is waiting on the object and the other thread send a signal, which then
- release the waiting thread.
- The signal must be able to be sent from interrupt context.
- This object is generally implemented by binary semaphore or events.
-
- \note On each porting or platform the type could be whatever is needed - integer, structure etc.
-
- \note belongs to \ref ported_sec
-*/
-typedef OsiSyncObj_t _SlSyncObj_t;
-
-
-/*!
- \brief This function creates a sync object
-
- The sync object is used for synchronization between diffrent thread or ISR and
- a thread.
-
- \param pSyncObj - pointer to the sync object control block
-
- \return upon successful creation the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
-
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_SyncObjCreate(pSyncObj,pName) osi_SyncObjCreate(pSyncObj)
-
-
-/*!
- \brief This function deletes a sync object
-
- \param pSyncObj - pointer to the sync object control block
-
- \return upon successful deletion the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_SyncObjDelete(pSyncObj) osi_SyncObjDelete(pSyncObj)
-
-
-/*!
- \brief This function generates a sync signal for the object.
-
- All suspended threads waiting on this sync object are resumed
-
- \param pSyncObj - pointer to the sync object control block
-
- \return upon successful signaling the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note the function could be called from ISR context
- \warning
-*/
-#define sl_SyncObjSignal(pSyncObj) osi_SyncObjSignal(pSyncObj)
-
-/*!
- \brief This function generates a sync signal for the object from Interrupt
-
- This is for RTOS that should signal from IRQ using a dedicated API
-
- \param pSyncObj - pointer to the sync object control block
-
- \return upon successful signaling the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note the function could be called from ISR context
- \warning
-*/
-#define sl_SyncObjSignalFromIRQ(pSyncObj) osi_SyncObjSignalFromISR(pSyncObj)
-
-/*!
- \brief This function waits for a sync signal of the specific sync object
-
- \param pSyncObj - pointer to the sync object control block
- \param Timeout - numeric value specifies the maximum number of mSec to
- stay suspended while waiting for the sync signal
- Currently, the simple link driver uses only two values:
- - OSI_WAIT_FOREVER
- - OSI_NO_WAIT
-
- \return upon successful reception of the signal within the timeout window return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_SyncObjWait(pSyncObj,Timeout) osi_SyncObjWait(pSyncObj,Timeout)
-
-/*!
- \brief type definition for a locking object container
-
- Locking object are used to protect a resource from mutual accesses of two or more threads.
- The locking object should suppurt reentrant locks by a signal thread.
- This object is generally implemented by mutex semaphore
-
- \note On each porting or platform the type could be whatever is needed - integer, structure etc.
- \note belongs to \ref ported_sec
-*/
-typedef OsiLockObj_t _SlLockObj_t;
-
-/*!
- \brief This function creates a locking object.
-
- The locking object is used for protecting a shared resources between different
- threads.
-
- \param pLockObj - pointer to the locking object control block
-
- \return upon successful creation the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_LockObjCreate(pLockObj,pName) osi_LockObjCreate(pLockObj)
-
-/*!
- \brief This function deletes a locking object.
-
- \param pLockObj - pointer to the locking object control block
-
- \return upon successful deletion the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_LockObjDelete(pLockObj) osi_LockObjDelete(pLockObj)
-
-/*!
- \brief This function locks a locking object.
-
- All other threads that call this function before this thread calls
- the osi_LockObjUnlock would be suspended
-
- \param pLockObj - pointer to the locking object control block
- \param Timeout - numeric value specifies the maximum number of mSec to
- stay suspended while waiting for the locking object
- Currently, the simple link driver uses only two values:
- - OSI_WAIT_FOREVER
- - OSI_NO_WAIT
-
-
- \return upon successful reception of the locking object the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_LockObjLock(pLockObj,Timeout) osi_LockObjLock(pLockObj,Timeout)
-
-/*!
- \brief This function unlock a locking object.
-
- \param pLockObj - pointer to the locking object control block
-
- \return upon successful unlocking the function should return 0
- Otherwise, a negative value indicating the error code shall be returned
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_LockObjUnlock(pLockObj) osi_LockObjUnlock(pLockObj)
-
-#endif
-/*!
- \brief This function call the pEntry callback from a different context
-
- \param pEntry - pointer to the entry callback function
-
- \param pValue - pointer to any type of memory structure that would be
- passed to pEntry callback from the execution thread.
-
- \param flags - execution flags - reserved for future usage
-
- \return upon successful registration of the spawn the function should return 0
- (the function is not blocked till the end of the execution of the function
- and could be returned before the execution is actually completed)
- Otherwise, a negative value indicating the error code shall be returned
- \note belongs to \ref ported_sec
- \warning
-*/
-//#define SL_PLATFORM_EXTERNAL_SPAWN
-
-#ifdef SL_PLATFORM_EXTERNAL_SPAWN
-#define sl_Spawn(pEntry,pValue,flags) osi_Spawn(pEntry,pValue,flags)
-#endif
-
-/*!
-
- Close the Doxygen group.
- @}
-
- */
-/*!
- ******************************************************************************
-
- \defgroup porting_mem_mgm Porting - Memory Management
-
- This section declare in which memory management model the SimpleLink driver
- will run:
- -# Static
- -# Dynamic
-
- This section IS NOT REQUIRED in case Static model is selected.
-
- The default memory model is Static
-
- PORTING ACTION:
- - If dynamic model is selected, define the alloc and free functions.
-
- @{
-
- *****************************************************************************
-*/
-
-/*!
- \brief Defines whether the SimpleLink driver is working in dynamic
- memory model or not
-
- When defined, the SimpleLink driver use dynamic allocations
- if dynamic allocation is selected malloc and free functions
- must be retrieved
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-
-#define SL_MEMORY_MGMT_DYNAMIC 1
-#define SL_MEMORY_MGMT_STATIC 0
-
-#define SL_MEMORY_MGMT SL_MEMORY_MGMT_STATIC
-
-#ifdef SL_MEMORY_MGMT_DYNAMIC
-#ifdef SL_PLATFORM_MULTI_THREADED
-
-/*!
- \brief
- \sa
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_Malloc(Size) mem_Malloc(Size)
-
-/*!
- \brief
- \sa
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_Free(pMem) mem_Free(pMem)
-#else
-#include <stdlib.h>
-/*!
- \brief
- \sa
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_Malloc(Size) malloc(Size)
-
-/*!
- \brief
- \sa
- \note belongs to \ref ported_sec
- \warning
-*/
-#define sl_Free(pMem) free(pMem)
-#endif
-#endif
-/*!
-
- Close the Doxygen group.
- @}
-
- */
-
-
-/*!
- ******************************************************************************
-
- \defgroup porting_events Porting - Event Handlers
-
- This section includes the asynchronous event handlers routines
-
- PORTING ACTION:
- -Uncomment the required handler and define your routine as the value
- of this handler
-
- @{
-
- ******************************************************************************
- */
-
-/*!
- \brief
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-
-#define sl_GeneralEvtHdlr SimpleLinkGeneralEventHandler
-
-
-/*!
- \brief An event handler for WLAN connection or disconnection indication
- This event handles async WLAN events.
- Possible events are:
- SL_WLAN_CONNECT_EVENT - indicates WLAN is connected
- SL_WLAN_DISCONNECT_EVENT - indicates WLAN is disconnected
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-
-#define sl_WlanEvtHdlr SimpleLinkWlanEventHandler
-
-
-/*!
- \brief An event handler for IP address asynchronous event. Usually accepted after new WLAN connection.
- This event handles networking events.
- Possible events are:
- SL_NETAPP_IPV4_ACQUIRED - IP address was acquired (DHCP or Static)
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-
-#define sl_NetAppEvtHdlr SimpleLinkNetAppEventHandler
-
-/*!
- \brief A callback for HTTP server events.
- Possible events are:
- SL_NETAPP_HTTPGETTOKENVALUE - NWP requests to get the value of a specific token
- SL_NETAPP_HTTPPOSTTOKENVALUE - NWP post to the host a new value for a specific token
-
- \param pServerEvent - Contains the relevant event information (SL_NETAPP_HTTPGETTOKENVALUE or SL_NETAPP_HTTPPOSTTOKENVALUE)
-
- \param pServerResponse - Should be filled by the user with the relevant response information (i.e SL_NETAPP_HTTPSETTOKENVALUE as a response to SL_NETAPP_HTTPGETTOKENVALUE event)
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-
-#define sl_HttpServerCallback SimpleLinkHttpServerCallback
-/*!
- \brief
-
- \sa
-
- \note belongs to \ref porting_sec
-
- \warning
-*/
-
-#define sl_SockEvtHdlr SimpleLinkSockEventHandler
-
-
-
-#define _SL_USER_TYPES
-#define _u8 unsigned char
-#define _i8 signed char
-
-#define _u16 unsigned short
-#define _i16 signed short
-
-#define _u32 unsigned int
-#define _i32 signed int
-#define _volatile volatile
-#define _const const
-
-
-
-/*!
-
- Close the Doxygen group.
- @}
-
- */
-
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif // __USER_H__