kopia lustrzana https://github.com/solokeys/solo1
build for solo
rodzic
c0a639cde5
commit
ae26e0c167
|
@ -9,4 +9,7 @@
|
|||
url = https://github.com/kmackay/micro-ecc.git
|
||||
[submodule "crypto/tiny-AES-c"]
|
||||
path = crypto/tiny-AES-c
|
||||
url = https://github.com/kokke/tiny-AES-c
|
||||
url = https://github.com/kokke/tiny-AES-c
|
||||
[submodule "targets/stm32l442/dfuse-tool"]
|
||||
path = targets/stm32l442/dfuse-tool
|
||||
url = https://github.com/SoloKeysSec/dfuse-tool
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CC=arm-none-eabi-gcc.exe
|
||||
CP=arm-none-eabi-objcopy.exe
|
||||
SZ=arm-none-eabi-size.exe
|
||||
CC=arm-none-eabi-gcc
|
||||
CP=arm-none-eabi-objcopy
|
||||
SZ=arm-none-eabi-size
|
||||
|
||||
SRC=src/main.c src/startup_stm32l432xx.s src/system_stm32l4xx.c $(wildcard lib/*c)
|
||||
OBJ=$(SRC:.c=.o)
|
||||
|
@ -12,7 +12,12 @@ CFLAGS= $(INC)
|
|||
TARGET=solo
|
||||
HW=-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb
|
||||
|
||||
CFLAGS=$(INC) -c -DSTM32L432xx -DUSE_FULL_LL_DRIVER -O0 -Wall -fdata-sections -ffunction-sections
|
||||
# Nucleo board
|
||||
#CHIP=STM32L432xx
|
||||
# Solo
|
||||
CHIP=STM32L442xx
|
||||
|
||||
CFLAGS=$(INC) -c -D$(CHIP) -DUSE_FULL_LL_DRIVER -O0 -Wall -fdata-sections -ffunction-sections
|
||||
LDFLAGS=$(HW) -specs=nano.specs -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections
|
||||
|
||||
all: $(TARGET).elf
|
||||
|
@ -32,5 +37,7 @@ clean:
|
|||
rm -f *.o src/*.o src/*.elf *.elf
|
||||
|
||||
flash:
|
||||
STM32_Programmer_CLI.exe -c port=SWD -halt -d $(TARGET).hex -rst
|
||||
STM32_Programmer_CLI -c port=SWD -halt -d $(TARGET).hex -rst
|
||||
sleep 0.5
|
||||
python dfuse-tool/dfuse-tool.py --leave
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
#MicroXplorer Configuration settings - do not modify
|
||||
File.Version=6
|
||||
KeepUserPlacement=false
|
||||
Mcu.Family=STM32L4
|
||||
Mcu.IP0=NVIC
|
||||
Mcu.IP1=RCC
|
||||
Mcu.IP2=SYS
|
||||
Mcu.IP3=USART1
|
||||
Mcu.IPNb=4
|
||||
Mcu.Name=STM32L442KCUx
|
||||
Mcu.Package=UFQFPN32
|
||||
Mcu.Pin0=PA9
|
||||
Mcu.Pin1=PA10
|
||||
Mcu.Pin2=VP_SYS_VS_Systick
|
||||
Mcu.PinsNb=3
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32L442KCUx
|
||||
MxCube.Version=4.27.0
|
||||
MxDb.Version=DB.4.0.270
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
PA10.Mode=Asynchronous
|
||||
PA10.Signal=USART1_RX
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PCC.Checker=true
|
||||
PCC.Line=STM32L4x2
|
||||
PCC.MCU=STM32L442KCUx
|
||||
PCC.PartNumber=STM32L442KCUx
|
||||
PCC.Seq0=0
|
||||
PCC.Series=STM32L4
|
||||
PCC.Temperature=25
|
||||
PCC.Vdd=null
|
||||
PinOutPanel.RotationAngle=0
|
||||
RCC.ADCFreq_Value=192000000
|
||||
RCC.AHBFreq_Value=48000000
|
||||
RCC.APB1CLKDivider=RCC_HCLK_DIV16
|
||||
RCC.APB1Freq_Value=3000000
|
||||
RCC.APB1TimFreq_Value=6000000
|
||||
RCC.APB2CLKDivider=RCC_HCLK_DIV16
|
||||
RCC.APB2Freq_Value=3000000
|
||||
RCC.APB2TimFreq_Value=6000000
|
||||
RCC.CortexFreq_Value=48000000
|
||||
RCC.FCLKCortexFreq_Value=48000000
|
||||
RCC.FamilyName=M
|
||||
RCC.HCLKFreq_Value=48000000
|
||||
RCC.HSE_VALUE=8000000
|
||||
RCC.HSI48_VALUE=48000000
|
||||
RCC.HSI_VALUE=16000000
|
||||
RCC.I2C1Freq_Value=3000000
|
||||
RCC.I2C3Freq_Value=3000000
|
||||
RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C3Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MSIClockRange,MSI_VALUE,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSAI1PoutputFreq_Value,PLLSAI1QoutputFreq_Value,PLLSAI1RoutputFreq_Value,PWRFreq_Value,RNGFreq_Value,SAI1Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,USART1Freq_Value,USART2Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAI1OutputFreq_Value
|
||||
RCC.LPTIM1Freq_Value=3000000
|
||||
RCC.LPTIM2Freq_Value=3000000
|
||||
RCC.LPUART1Freq_Value=3000000
|
||||
RCC.LSCOPinFreq_Value=32000
|
||||
RCC.LSE_VALUE=32768
|
||||
RCC.LSI_VALUE=32000
|
||||
RCC.MCO1PinFreq_Value=48000000
|
||||
RCC.MSIClockRange=RCC_MSIRANGE_11
|
||||
RCC.MSI_VALUE=48000000
|
||||
RCC.PLLPoutputFreq_Value=54857142.85714286
|
||||
RCC.PLLQoutputFreq_Value=192000000
|
||||
RCC.PLLRCLKFreq_Value=192000000
|
||||
RCC.PLLSAI1PoutputFreq_Value=54857142.85714286
|
||||
RCC.PLLSAI1QoutputFreq_Value=192000000
|
||||
RCC.PLLSAI1RoutputFreq_Value=192000000
|
||||
RCC.PWRFreq_Value=48000000
|
||||
RCC.RNGFreq_Value=192000000
|
||||
RCC.SAI1Freq_Value=54857142.85714286
|
||||
RCC.SWPMI1Freq_Value=3000000
|
||||
RCC.SYSCLKFreq_VALUE=48000000
|
||||
RCC.USART1Freq_Value=3000000
|
||||
RCC.USART2Freq_Value=3000000
|
||||
RCC.USBFreq_Value=192000000
|
||||
RCC.VCOInputFreq_Value=48000000
|
||||
RCC.VCOOutputFreq_Value=384000000
|
||||
RCC.VCOSAI1OutputFreq_Value=384000000
|
||||
USART1.IPParameters=VirtualMode-Asynchronous
|
||||
USART1.VirtualMode-Asynchronous=VM_ASYNC
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
board=custom
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
#define Error_Handler() _Error_Handler(__FILE__,__LINE__)
|
||||
|
||||
#define VCP_TX_Pin LL_GPIO_PIN_2
|
||||
#define VCP_RX_Pin LL_GPIO_PIN_15
|
||||
#define VCP_TX_GPIO_Port GPIOA
|
||||
#define VCP_RX_GPIO_Port GPIOA
|
||||
#define VCP_TX_Pin LL_GPIO_PIN_6
|
||||
#define VCP_RX_Pin LL_GPIO_PIN_7
|
||||
#define VCP_TX_GPIO_Port GPIOB
|
||||
#define VCP_RX_GPIO_Port GPIOB
|
||||
|
||||
void _Error_Handler(char *file, int line);
|
||||
|
||||
|
@ -37,7 +37,7 @@ void uart_write(USART_TypeDef *uart, uint8_t * data, uint32_t len)
|
|||
}
|
||||
}
|
||||
|
||||
void MX_USART2_UART_Init(void)
|
||||
void MX_USART1_UART_Init(void)
|
||||
{
|
||||
|
||||
LL_USART_InitTypeDef USART_InitStruct;
|
||||
|
@ -45,27 +45,19 @@ void MX_USART2_UART_Init(void)
|
|||
LL_GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
|
||||
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX
|
||||
PA15 (JTDI) ------> USART2_RX
|
||||
/**USART1 GPIO Configuration
|
||||
PB6 ------> USART1_TX
|
||||
PB7 ------> USART1_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = VCP_TX_Pin;
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_6|LL_GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(VCP_TX_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = VCP_RX_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_3;
|
||||
LL_GPIO_Init(VCP_RX_GPIO_Port, &GPIO_InitStruct);
|
||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
USART_InitStruct.BaudRate = 115200;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
|
@ -74,96 +66,85 @@ void MX_USART2_UART_Init(void)
|
|||
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
|
||||
USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
|
||||
USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;
|
||||
LL_USART_Init(USART2, &USART_InitStruct);
|
||||
LL_USART_Init(USART1, &USART_InitStruct);
|
||||
|
||||
LL_USART_ConfigAsyncMode(USART2);
|
||||
LL_USART_ConfigAsyncMode(USART1);
|
||||
|
||||
LL_USART_Enable(USART2);
|
||||
LL_USART_Enable(USART1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Generated via cube
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
|
||||
LL_FLASH_SetLatency(LL_FLASH_LATENCY_2);
|
||||
LL_FLASH_SetLatency(LL_FLASH_LATENCY_2);
|
||||
|
||||
if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
|
||||
if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
|
||||
|
||||
LL_RCC_MSI_Enable();
|
||||
LL_RCC_MSI_Enable();
|
||||
|
||||
/* Wait till MSI is ready */
|
||||
while(LL_RCC_MSI_IsReady() != 1)
|
||||
{
|
||||
/* Wait till MSI is ready */
|
||||
while(LL_RCC_MSI_IsReady() != 1)
|
||||
{
|
||||
|
||||
}
|
||||
LL_RCC_MSI_EnableRangeSelection();
|
||||
|
||||
}
|
||||
LL_RCC_MSI_EnablePLLMode();
|
||||
LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_11);
|
||||
|
||||
LL_RCC_MSI_EnableRangeSelection();
|
||||
LL_RCC_MSI_SetCalibTrimming(0);
|
||||
|
||||
LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_11);
|
||||
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_MSI);
|
||||
|
||||
LL_RCC_MSI_SetCalibTrimming(0);
|
||||
/* Wait till System clock is ready */
|
||||
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_MSI)
|
||||
{
|
||||
|
||||
}
|
||||
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
|
||||
|
||||
LL_PWR_EnableBkUpAccess();
|
||||
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_16);
|
||||
|
||||
LL_RCC_LSE_SetDriveCapability(LL_RCC_LSEDRIVE_LOW);
|
||||
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_16);
|
||||
|
||||
LL_RCC_LSE_Enable();
|
||||
LL_Init1msTick(48000000);
|
||||
|
||||
/* Wait till LSE is ready */
|
||||
while(LL_RCC_LSE_IsReady() != 1)
|
||||
{
|
||||
LL_SYSTICK_SetClkSource(LL_SYSTICK_CLKSOURCE_HCLK);
|
||||
|
||||
}
|
||||
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_MSI);
|
||||
LL_SetSystemCoreClock(48000000);
|
||||
|
||||
/* Wait till System clock is ready */
|
||||
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_MSI)
|
||||
{
|
||||
LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2);
|
||||
|
||||
}
|
||||
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
|
||||
|
||||
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_16);
|
||||
|
||||
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_16);
|
||||
|
||||
LL_Init1msTick(48000000);
|
||||
|
||||
LL_SYSTICK_SetClkSource(LL_SYSTICK_CLKSOURCE_HCLK);
|
||||
|
||||
LL_SetSystemCoreClock(48000000);
|
||||
|
||||
LL_RCC_SetUSARTClockSource(LL_RCC_USART2_CLKSOURCE_PCLK1);
|
||||
|
||||
/* SysTick_IRQn interrupt configuration */
|
||||
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
|
||||
/* SysTick_IRQn interrupt configuration */
|
||||
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
|
||||
}
|
||||
|
||||
#define LED_PIN LL_GPIO_PIN_3
|
||||
#define LED_PORT GPIOB
|
||||
#define LED_PIN_G LL_GPIO_PIN_0
|
||||
#define LED_PIN_B LL_GPIO_PIN_1
|
||||
#define LED_PIN_R LL_GPIO_PIN_2
|
||||
#define LED_PORT GPIOA
|
||||
void hw_init()
|
||||
{
|
||||
|
||||
SystemClock_Config();
|
||||
/*SystemClock_Config();*/
|
||||
// initialize GPIO
|
||||
// Enable clock to A,B,C
|
||||
SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN);
|
||||
SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN);
|
||||
SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN);
|
||||
LL_GPIO_SetPinMode(LED_PORT, LED_PIN, LL_GPIO_MODE_OUTPUT);
|
||||
LL_GPIO_SetPinMode(LED_PORT, LED_PIN_R, LL_GPIO_MODE_OUTPUT);
|
||||
LL_GPIO_SetPinMode(LED_PORT, LED_PIN_G, LL_GPIO_MODE_OUTPUT);
|
||||
LL_GPIO_SetPinMode(LED_PORT, LED_PIN_B, LL_GPIO_MODE_OUTPUT);
|
||||
/* NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);*/
|
||||
/*SystemClock_Config();*/
|
||||
|
||||
|
||||
MX_USART2_UART_Init();
|
||||
/*MX_USART1_UART_Init();*/
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
@ -174,10 +155,25 @@ int main(void)
|
|||
|
||||
while (1)
|
||||
{
|
||||
LL_GPIO_TogglePin(LED_PORT, LED_PIN);
|
||||
delay(500);
|
||||
/*LL_GPIO_TogglePin(LED_PORT, LED_PIN_R);*/
|
||||
/*LL_GPIO_TogglePin(LED_PORT, LED_PIN_R);*/
|
||||
/*LL_GPIO_TogglePin(LED_PORT, LED_PIN_G);*/
|
||||
/*LL_GPIO_TogglePin(LED_PORT, LED_PIN_B);*/
|
||||
|
||||
LL_GPIO_SetOutputPin(LED_PORT, LED_PIN_R);
|
||||
LL_GPIO_SetOutputPin(LED_PORT, LED_PIN_G);
|
||||
LL_GPIO_SetOutputPin(LED_PORT, LED_PIN_B);
|
||||
|
||||
LL_GPIO_ResetOutputPin(LED_PORT, LED_PIN_R);
|
||||
/*LL_GPIO_ResetOutputPin(LED_PORT, LED_PIN_G);*/
|
||||
/*LL_GPIO_ResetOutputPin(LED_PORT, LED_PIN_B);*/
|
||||
|
||||
|
||||
/*delay(10);*/
|
||||
msg[3] = i++;
|
||||
uart_write(USART2, msg, sizeof(msg));
|
||||
while (1)
|
||||
;
|
||||
/*uart_write(USART2, msg, sizeof(msg));*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue