Replicate the wormhole in the bootloader and make it jump to the application if it's open and the enumeration mode is anything but EnumerationMode_Bootloader.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "property/property.h"
|
||||
#include "utilities/vector_table_info.h"
|
||||
#include "utilities/fsl_rtos_abstraction.h"
|
||||
#include "bootloader/wormhole.h"
|
||||
#if BL_FEATURE_CRC_CHECK
|
||||
#include "bootloader/bl_app_crc_check.h"
|
||||
#endif
|
||||
@@ -321,7 +322,7 @@ static peripheral_descriptor_t const *get_active_peripheral(void)
|
||||
{
|
||||
if (is_direct_boot())
|
||||
{
|
||||
if (RCM->SRS0 & RCM_SRS0_POR_MASK) {
|
||||
if (RCM->SRS0 & RCM_SRS0_POR_MASK || (IS_WORMHOLE_OPEN && Wormhole.enumerationMode != EnumerationMode_Bootloader)) {
|
||||
jump_to_application(applicationAddress, stackPointer);
|
||||
}
|
||||
}
|
||||
|
||||
3
src/bootloader/src/wormhole.c
Normal file
3
src/bootloader/src/wormhole.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "bootloader/wormhole.h"
|
||||
|
||||
wormhole_t __attribute__ ((used, section (".noinit"))) Wormhole;
|
||||
32
src/bootloader/wormhole.h
Normal file
32
src/bootloader/wormhole.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef __WORMHOLE_H__
|
||||
#define __WORMHOLE_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Macros:
|
||||
|
||||
#define WORMHOLE_MAGIC_NUMBER 0x3b04cd9e94521f9a
|
||||
#define IS_WORMHOLE_OPEN (Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER)
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef enum {
|
||||
EnumerationMode_Bootloader,
|
||||
EnumerationMode_BusPal,
|
||||
EnumerationMode_NormalKeyboard,
|
||||
EnumerationMode_CompatibleKeyboard,
|
||||
} enumeration_mode_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t magicNumber;
|
||||
uint8_t enumerationMode;
|
||||
uint16_t timeoutMs;
|
||||
} wormhole_t;
|
||||
|
||||
// Variables:
|
||||
|
||||
extern wormhole_t __attribute__ ((section (".noinit"))) Wormhole;
|
||||
|
||||
#endif
|
||||
@@ -215,6 +215,11 @@
|
||||
<type>2</type>
|
||||
<locationURI>virtual:/virtual</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>src/bootloader/wormhole.h</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-4-PROJECT_LOC/src/bootloader/wormhole.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>src/crc/crc16.h</name>
|
||||
<type>1</type>
|
||||
@@ -445,6 +450,11 @@
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-4-PROJECT_LOC/src/bootloader/src/usb_hid_msc_peripheral_interface.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>src/bootloader/src/wormhole.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-4-PROJECT_LOC/src/bootloader/src/wormhole.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>src/crc/src/crc16.c</name>
|
||||
<type>1</type>
|
||||
|
||||
@@ -61,7 +61,8 @@ MEMORY
|
||||
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
|
||||
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
|
||||
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0
|
||||
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00020000
|
||||
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x0001FF00
|
||||
m_noinit (RW) : ORIGIN = 0x2000FF00, LENGTH = 0x00000100
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
@@ -255,5 +256,16 @@ SECTIONS
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region m_data_2 overflowed with stack and heap")
|
||||
|
||||
.noinit (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_noinit = .;
|
||||
|
||||
*(.noinit .noinit.*)
|
||||
|
||||
. = ALIGN(4) ;
|
||||
_end_noinit = .;
|
||||
} > m_noinit
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user