Update README.md

Adapt code to UHK HW and FW (bl_main.c and shutdown_cleanup.c)
Change vector reset configuration (MK22F51212/src/startup/gcc/startup_MK22F51212.S)
Adapt peripheral configuration and start address of UHK (bootloader_config.h)
Adapt clock configuration to make it compatible with UHK.
Added binaries to test the bootloader.
This commit is contained in:
santiagogf89@gmail.com
2016-11-13 19:17:01 +01:00
parent f3dfaa4bb7
commit 91996c28fc
8 changed files with 4379 additions and 50 deletions

View File

@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SGF Original KBOOT file modified */
#include <stdbool.h>
#include "utilities/fsl_assert.h"
#include "bootloader/bl_context.h"
@@ -65,6 +67,7 @@
static const char *get_peripheral_name(uint32_t peripheralTypeMask);
#endif
#if !BL_FEATURE_TIMEOUT
static void get_user_application_entry(uint32_t *appEntry, uint32_t *appStack);
static void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer);
@@ -196,6 +199,7 @@ static void jump_to_application(uint32_t applicationAddress, uint32_t stackPoint
__set_MSP(s_stackPointer);
__set_PSP(s_stackPointer);
// while (1); /* SGF REMOVE */
// Jump to the application.
farewellBootloader();
// Dummy fcuntion call, should never go to this fcuntion call
@@ -305,10 +309,7 @@ static peripheral_descriptor_t const *get_active_peripheral(void)
#if !BL_FEATURE_TIMEOUT
uint64_t lastTicks = 0; // Value of our last recorded ticks second marker
uint64_t timeoutTicks = 0; // The number of ticks we will wait for timeout, 0 means no timeout
#if BL_FEATURE_POWERDOWN
bool shortTimeout = false;
#endif
uint64_t timeoutTicks = 120000000; // SGF Add timeout to make the bootloader Jump to application after some time. 0 means no timeout.
const uint64_t ticksPerMillisecond = microseconds_convert_to_ticks(1000);
// Get the user application entry point and stack pointer.
@@ -320,7 +321,7 @@ static peripheral_descriptor_t const *get_active_peripheral(void)
{
if (is_direct_boot())
{
jump_to_application(applicationAddress, stackPointer);
//jump_to_application(applicationAddress, stackPointer);
}
// Calculate how many ticks we need to wait based on the bootloader config. Check to see if
@@ -339,17 +340,7 @@ static peripheral_descriptor_t const *get_active_peripheral(void)
// save how many ticks we're currently at before the detection loop starts
lastTicks = microseconds_get_ticks();
#if BL_FEATURE_POWERDOWN
shortTimeout = true;
#endif
}
#if BL_FEATURE_POWERDOWN
else
{
timeoutTicks = BL_DEFAULT_POWERDOWN_TIMEOUT * ticksPerMillisecond;
lastTicks = microseconds_get_ticks();
}
#endif
#endif // !BL_FEATURE_TIMEOUT
// Wait for a peripheral to become active
@@ -367,28 +358,10 @@ static peripheral_descriptor_t const *get_active_peripheral(void)
// Check if the elapsed time is longer than the timeout.
if (elapsedTicks >= timeoutTicks)
{
#if BL_FEATURE_POWERDOWN
if (shortTimeout)
{
#endif
// In the case of the typical peripheral timeout, jump to the user application.
jump_to_application(applicationAddress, stackPointer);
#if BL_FEATURE_POWERDOWN
}
else
{
// Make sure a timeout value has been defined before shutting down.
if (BL_DEFAULT_POWERDOWN_TIMEOUT)
{
// Shut down the bootloader and return to reset-type state prior to low
// power entry
shutdown_cleanup(kShutdownType_Shutdown);
// Enter VLLS1 low power mode
enter_vlls1();
}
}
#endif
if (is_application_ready_for_executing(applicationAddress)) {
jump_to_application(applicationAddress, stackPointer);
}
}
}
#endif // !BL_FEATURE_TIMEOUT

View File

@@ -27,6 +27,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SGF Original KBOOT file modified */
#if !defined(BOOTLOADER_HOST)
#include "fsl_device_registers.h"
#include "utilities/fsl_rtos_abstraction.h"
@@ -96,7 +99,7 @@ void shutdown_cleanup(shutdown_type_t shutdown)
SCB->VTOR = kDefaultVectorTableAddress;
// Restore clock to default before leaving bootloader.
configure_clocks(kClockOption_ExitBootloader);
//configure_clocks(kClockOption_ExitBootloader); // SGF We have disabled this call in order to reach the UHK FW with a valid Clock Config.
// De-initialize hardware such as disabling port clock gate
deinit_hardware();