mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 02:55:49 +00:00
Add testing bootloader for stereo_mix
This commit is contained in:
parent
8a343ae4fb
commit
f9dd6af68a
5 changed files with 124 additions and 11 deletions
70
stereo_mix/bootloader/bootloader.cc
Normal file
70
stereo_mix/bootloader/bootloader.cc
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#include <stm32f0xx_hal.h>
|
||||||
|
#include <stm32f0xx_ll_bus.h>
|
||||||
|
#include <stm32f0xx_ll_system.h>
|
||||||
|
|
||||||
|
#include "stmlib/system/bootloader_utils.h"
|
||||||
|
#include "stmlib/system/system_clock.h"
|
||||||
|
|
||||||
|
using namespace stmlib;
|
||||||
|
|
||||||
|
extern "C" void __cxa_pure_virtual()
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
void Error_Handler(void)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
void SysTick_Handler()
|
||||||
|
{
|
||||||
|
system_clock.Tick();
|
||||||
|
}
|
||||||
|
void SystemClock_Config(void)
|
||||||
|
{
|
||||||
|
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
|
||||||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
|
||||||
|
|
||||||
|
/** Initializes the CPU, AHB and APB busses clocks
|
||||||
|
*/
|
||||||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI14 | RCC_OSCILLATORTYPE_HSE;
|
||||||
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||||
|
RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
|
||||||
|
RCC_OscInitStruct.HSI14CalibrationValue = 16;
|
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||||
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
|
||||||
|
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
|
||||||
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/** Initializes the CPU, AHB and APB busses clocks
|
||||||
|
*/
|
||||||
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
|
||||||
|
| RCC_CLOCKTYPE_PCLK1;
|
||||||
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||||
|
|
||||||
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const uint32_t kStartAddress = 0x08002000;
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
HAL_Init();
|
||||||
|
SystemClock_Config();
|
||||||
|
|
||||||
|
// todo: do bootloader things
|
||||||
|
HAL_DeInit();
|
||||||
|
Uninitialize();
|
||||||
|
__disable_irq();
|
||||||
|
JumpTo(kStartAddress);
|
||||||
|
}
|
41
stereo_mix/bootloader/makefile
Normal file
41
stereo_mix/bootloader/makefile
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# Copyright 2013 Emilie Gillet.
|
||||||
|
#
|
||||||
|
# Author: Emilie Gillet (emilie.o.gillet@gmail.com)
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# See http://creativecommons.org/licenses/MIT/ for more information.
|
||||||
|
|
||||||
|
# System specifications
|
||||||
|
F_CRYSTAL = 8000000L
|
||||||
|
F_CPU = 72000000L
|
||||||
|
SYSCLOCK = SYSCLK_FREQ_72MHz
|
||||||
|
FAMILY = f0xx
|
||||||
|
OPTIMIZE = TRUE
|
||||||
|
OPTIMIZE_FLAG = s
|
||||||
|
|
||||||
|
# Preferred upload command
|
||||||
|
UPLOAD_COMMAND = upload_jtag
|
||||||
|
|
||||||
|
# Packages to build
|
||||||
|
TARGET = stereo_mix_bootloader
|
||||||
|
PACKAGES = stereo_mix/bootloader stmlib/utils stmlib/system
|
||||||
|
RESOURCES = stereo_mix/resources
|
||||||
|
|
||||||
|
include stmlib/makefile.inc
|
|
@ -24,17 +24,17 @@
|
||||||
# See http://creativecommons.org/licenses/MIT/ for more information.
|
# See http://creativecommons.org/licenses/MIT/ for more information.
|
||||||
|
|
||||||
# System specifications
|
# System specifications
|
||||||
F_CRYSTAL = 8000000L
|
F_CRYSTAL = 8000000L
|
||||||
F_CPU = 72000000L
|
F_CPU = 72000000L
|
||||||
SYSCLOCK = SYSCLK_FREQ_72MHz
|
SYSCLOCK = SYSCLK_FREQ_72MHz
|
||||||
FAMILY = f0xx
|
FAMILY = f0xx
|
||||||
# USB = enabled
|
APPLICATION_MEDIUM = TRUE
|
||||||
#APPLICATION = true
|
BOOTLOADER = stereo_mix_bootloader
|
||||||
#BOOTLOADER = midi2cv_bootloader
|
OPTIMIZE = TRUE
|
||||||
OPTIMIZE = TRUE
|
OPTIMIZE_FLAG = 2
|
||||||
OPTIMIZE_FLAG = 2
|
|
||||||
# Preferred upload command
|
# Preferred upload command
|
||||||
UPLOAD_COMMAND = upload_jtag
|
UPLOAD_COMMAND = upload_combo_jtag
|
||||||
|
|
||||||
# Packages to build
|
# Packages to build
|
||||||
TARGET = stereo_mix
|
TARGET = stereo_mix
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "stmlib/ui/event_queue.h"
|
#include "stmlib/ui/event_queue.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include <stm32f0xx_hal.h>
|
#include <stm32f0xx_hal.h>
|
||||||
|
#include "stmlib/system/bootloader_utils.h"
|
||||||
|
|
||||||
using namespace stereo_mix;
|
using namespace stereo_mix;
|
||||||
using namespace stmlib;
|
using namespace stmlib;
|
||||||
|
@ -167,6 +168,7 @@ void WriteOutputs(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
HAL_Init();
|
HAL_Init();
|
||||||
|
|
2
stmlib
2
stmlib
|
@ -1 +1 @@
|
||||||
Subproject commit e5d7705dbabd7e6827057d8a30be44d0ca55c6d6
|
Subproject commit 727d85a263af4ee4c2d8dd75191e2611383b9d29
|
Loading…
Reference in a new issue