1、启动文件“startup_S7G2.c”

  中断向量表地址指针:“0xe000ed08”

/* Vector table. */
BSP_DONT_REMOVE const exc_ptr_t __Vectors[BSP_CORTEX_VECTOR_TABLE_ENTRIES] BSP_PLACE_IN_SECTION(BSP_SECTION_VECTOR) =
{
(exc_ptr_t)(&g_main_stack[] + BSP_CFG_STACK_MAIN_BYTES), /* Initial Stack Pointer */
Reset_Handler, /* Reset Handler */
NMI_Handler, /* NMI Handler */
HardFault_Handler, /* Hard Fault Handler */
MemManage_Handler, /* MPU Fault Handler */
BusFault_Handler, /* Bus Fault Handler */
UsageFault_Handler, /* Usage Fault Handler */
, /* Reserved */
, /* Reserved */
, /* Reserved */
, /* Reserved */
SVC_Handler, /* SVCall Handler */
DebugMon_Handler, /* Debug Monitor Handler */
, /* Reserved */
PendSV_Handler, /* PendSV Handler */
SysTick_Handler, /* SysTick Handler */
};

2、“入口函数”在“链接脚本”中配置,S7G2.ld

/* Linker script to configure memory regions. */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x0040000 /* 256K */
RAM (rwx) : ORIGIN = 0x1FFE0000, LENGTH = 0x00A0000 /* 640K */
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x0010000 /* 64K */
QSPI_FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 0x0800000 /* 8M, Change in QSPI section below also */
SDRAM (rwx) : ORIGIN = 0x90000000, LENGTH = 0x2000000 /* 32M */
} ENTRY(Reset_Handler)

入口函数如下:

/***********************************************************************************************************************
* Function Name: Reset_Handler
* Description : MCU starts executing here out of reset. Main stack pointer is setup already.
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
void Reset_Handler (void)
{
/* Initialize system using BSP. */
SystemInit(); /* Call user application. */
main(); while ()
{
/* Infinite Loop. */
}
}

HOOK设置 R_BSP_WarmStart(),用户可以有机会在“main()”执行前加入自己的操作。如:BOOT下判断是否有OTA升级。

void SystemInit (void)
{
#if ( defined ( __GNUC__ ) && defined (__VFP_FP__) && !defined (__SOFTFP__) ) || \
( defined ( __ICCARM__ ) && defined ( __ARMVFP__ ) && (__FPU_PRESENT == ) ) /* Enable the Cortex-M4 FPU only when -mfloat-abi=hard.
Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C) */ /* Set bits 20-23 to enable CP10 and CP11 coprocessor */ /*LDRA_NOANALYSIS LDRA_INSPECTED below not working. */
/*LDRA_INSPECTED 96 S *//*LDRA_INSPECTED 93 S SCB is a CMSIS defined element over which we have no control.*/
SCB->CPACR = (uint32_t)((uint32_t)SCB->CPACR | (uint32_t)CP_MASK);
/*LDRA_ANALYSIS */
#endif /* Call Pre C runtime initialization hook. */
R_BSP_WarmStart(BSP_WARM_START_PRE_C); /* Initialize grouped interrupts. */
bsp_group_interrupt_open(); /* Initialize FMI. */
g_fmi_on_fmi.init(); /* Initialize register protection. */
bsp_register_protect_open(); /* Configure system clocks using CGC module. */
bsp_clock_init(); /* Temporary fix to initialize ioport reference counter to 0, needed before C runtime init. This will be removed
* in the next release in favor of a more complete solution. */
HW_IOPORT_Init_Reference_Counter(); /* Initialize pins. */
g_ioport_on_ioport.init(&g_bsp_pin_cfg); /* Initialize C runtime environment. */
/* Zero out BSS */
#if defined(__GNUC__)
bsp_section_zero((uint8_t *)&__bss_start__, ((uint32_t)&__bss_end__ - (uint32_t)&__bss_start__));
#elif defined(__ICCARM__)
bsp_section_zero((uint8_t *)__section_begin(".bss"), (uint32_t)__section_size(".bss"));
#endif /* Copy initialized RAM data from ROM to RAM. */
#if defined(__GNUC__)
bsp_section_copy((uint8_t *)&__etext,
(uint8_t *)&__data_start__,
((uint32_t)&__data_end__ - (uint32_t)&__data_start__));
#elif defined(__ICCARM__)
bsp_section_copy((uint8_t *)__section_begin(".data_init"),
(uint8_t *)__section_begin(".data"),
(uint32_t)__section_size(".data"));
/* Copy functions to be executed from RAM. */
#pragma section=".code_in_ram"
#pragma section=".code_in_ram_init"
bsp_section_copy((uint8_t *)__section_begin(".code_in_ram_init"),
(uint8_t *)__section_begin(".code_in_ram"),
(uint32_t)__section_size(".code_in_ram"));
/* Copy main thread TLS to RAM. */
#pragma section="__DLIB_PERTHREAD_init"
#pragma section="__DLIB_PERTHREAD"
bsp_section_copy((uint8_t *)__section_begin("__DLIB_PERTHREAD_init"),
(uint8_t *)__section_begin("__DLIB_PERTHREAD"),
(uint32_t)__section_size("__DLIB_PERTHREAD_init"));
#endif /* Initialize SystemCoreClock variable. */
SystemCoreClockUpdate(); /* Call Post C runtime initialization hook. */
R_BSP_WarmStart(BSP_WARM_START_POST_C); /* Initialize Static Constructors */
#if defined(__GNUC__)
/*LDRA_INSPECTED 219 S In the GCC compiler, __init_array_start and __init_array_end starts with underscore. */
/*LDRA_INSPECTED 219 S */
int32_t count = __init_array_end - __init_array_start;
for (int32_t i = ; i < count; i++)
{
__init_array_start [i]();
}
#elif defined(__ICCARM__)
void const * pibase = __section_begin("SHT$$PREINIT_ARRAY");
void const * ilimit = __section_end("SHT$$INIT_ARRAY");
__call_ctors(pibase, ilimit);
#endif /* Initialize the Hardware locks to 'Unlocked' */
bsp_init_hardware_locks(); /* Initialize ELC events that will be used to trigger NVIC interrupts. */
bsp_irq_cfg(); /* Initialize ELC. */
g_elc_on_elc.init(&g_elc_cfg); /* Call any BSP specific code. No arguments are needed so NULL is sent. */
bsp_init(NULL);
}

R_BSP_WarmStart()下实现的“BCH”升级

void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
if (BSP_WARM_START_PRE_C == event)
{
/* C runtime environment has not been setup so you cannot use globals. System clocks and pins are not setup. */
} else if (BSP_WARM_START_POST_C == event)
{
/* if S5 is pressed */
if ( == ((R_IOPORT0->PCNTR2 >> ) & 0x1))
{
boot_status = ;
} /* if S4 is pressed */
else if ( == ((R_IOPORT0->PCNTR2 >> ) & 0x1))
{
boot_status = ;
} /* if S4 and S5 are not pressed */
else
{
/* Initialize the Hardware locks to 'Unlocked' */
bsp_init_hardware_locks(); ssp_err_t status; status = g_sf_bootloader_mcu.p_api->open(g_sf_bootloader_mcu.p_ctrl, g_sf_bootloader_mcu.p_cfg);
if (!status)
{
status = g_sf_bootloader_mcu.p_api->appStart(g_sf_bootloader_mcu.p_ctrl);
if (status)
{
/* Notify the bootloader that appStart failed */
boot_status = ; g_sf_bootloader_mcu.p_api->close(g_sf_bootloader_mcu.p_ctrl);
}
} else
{
/* Notify the bootloader that open failed */
boot_status = ;
}
}
} else
{
/* Do nothing */
}
}

当然也可以判断DATA FLASH数据作为是否升级的依据:

Synergy CORTEX M 启动流程的更多相关文章

  1. 转载-Qualcomm MSM8953启动流程:PBL-SBL1-(bootloader)LK-Android

    文章转载链接: https://blog.csdn.net/RadianceBlau/article/details/73229005 对于嵌入式工程师了解芯片启动过程是十分有必要的,在分析.调试各种 ...

  2. MyCat源码分析系列之——配置信息和启动流程

    更多MyCat源码分析,请戳MyCat源码分析系列 MyCat配置信息 除了一些默认的配置参数,大多数的MyCat配置信息是通过读取若干.xml/.properties文件获取的,主要包括: 1)se ...

  3. Android进阶系列之源码分析Activity的启动流程

    美女镇楼,辟邪! 源码,是一个程序猿前进路上一个大的而又不得不去翻越障碍,我讨厌源码,看着一大堆.5000多行,要看完得啥时候去了啊.不过做安卓的总有这一天,自从踏上这条不归路,我就认命了.好吧,我慢 ...

  4. Spring Boot启动流程详解(一)

    环境 本文基于Spring Boot版本1.3.3, 使用了spring-boot-starter-web. 配置完成后,编写了代码如下: @SpringBootApplication public ...

  5. linux启动流程及自定义gurb

    linux 启动流程 POST BIOS(boot sequence) 所选择的启动设备次序的MBR中是否有引导程序, ----> MBR(bootloader) 提供内核列表 -------& ...

  6. linux启动流程

    看了深入理解linux内核一书的最后对linux启动流程的介绍,下面就把我能理解的写一下吧: bios(硬件加电自检POST,寻找第一个启动设备) the boot loader(可以从硬盘启动也可以 ...

  7. webapp启动流程

    webapp启动流程 看了这个教程,其实所有的webapp大致都是这个流程了.

  8. Tomcat源码分析之—具体启动流程分析

    从Tomcat启动调用栈可知,Bootstrap类的main方法为整个Tomcat的入口,在init初始化Bootstrap类的时候为设置Catalina的工作路径也就是Catalina_HOME信息 ...

  9. 嵌入式Linux驱动学习之路(五)u-boot启动流程分析

    这里说的u-boot启动流程,值得是从上电开机执行u-boot,到u-boot,到u-boot加载操作系统的过程.这一过程可以分为两个过程,各个阶段的功能如下. 第一阶段的功能: 硬件设备初始化. 加 ...

随机推荐

  1. iptables详解(6):iptables扩展匹配条件之’–tcp-flags’

    如果你看过前文,那么你一定知道,前文已经对"tcp扩展模块"做过总结,但是只总结了tcp扩展模块中的"--sport"与"--dport"选 ...

  2. influxdb和boltDB简介——MVCC+B+树,Go写成,Bolt类似于LMDB,这个被认为是在现代kye/value存储中最好的,influxdb后端存储有LevelDB换成了BoltDB

    influxdb influxdb是最新的一个时间序列数据库,最新一两年才产生,但已经拥有极高的人气.influxdb 是用Go写的,0.9版本的influxdb对于之前会有很大的改变,后端存储有Le ...

  3. RabbitMQ(6) 集群部署

    单节点部署 rabbitmq单节点部署比较简单,可以使用apt-get等工具快速安装部署. wget -O- https://www.rabbitmq.com/rabbitmq-release-sig ...

  4. CMDB Autoclient思路分析

    1.start.py里的script.run():执行run函数--> 2.script.py run方法--> 3.判断模式MODE(Agent/SSHSALT)-->4.执行cl ...

  5. vs 2013远程调试

    1. 找到本机Remote Debugger/x64文件夹,将其拷贝到远程机器上 2.运行x64文件夹下的msvsmon.exe,将其设置为“无身份验证模式”,记住端口号,一会儿要用到 3.在vs中打 ...

  6. pgpool安装配置整理

    安装PostgreSQL并配置三节点流复制环境,就不仔细说了,大致步骤如下: 1.下载源码 2.解压安装,如果在./configure --prefix=/usr/pgsql-10执行时提示要--wi ...

  7. EasyDarwin如何支持点播和RTMP/HLS直播?EasyDSS!

    2017年很长很长一段时间没有更新EasyDarwin开源项目了,虽然心里有很多EasyDarwin功能扩展的计划:比如同步录像.同步RTMP/HLS直播输出.拉模式转发优化.Onvif接入.GB28 ...

  8. Vim技能修炼教程(15) - 时间和日期相关函数

    Vimscript武器库 前面我们走马观花地将Vimscript的大致语法过了一遍.下面我们开始深入看一下Vimscript都给我们准备了哪些武器.如果只用这些武器就够了,那么就太好了,只用Vimsc ...

  9. kd树 求k近邻 python 代码

      之前两篇随笔介绍了kd树的原理,并用python实现了kd树的构建和搜索,具体可以参考 kd树的原理 python kd树 搜索 代码 kd树常与knn算法联系在一起,knn算法通常要搜索k近邻, ...

  10. python sys.path.append()和sys.path.insert()

    python程序中使用 import XXX 时,python解析器会在当前目录.已安装和第三方模块中搜索 xxx,如果都搜索不到就会报错. 使用sys.path.append()方法可以临时添加搜索 ...