This commit is contained in:
Mysteo91
2023-08-17 16:19:53 +03:00
parent c6211b1db1
commit 275752357a
13 changed files with 104 additions and 29 deletions

View File

@@ -1,9 +1,10 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="OCD Boot" type="com.jetbrains.cidr.embedded.openocd.conf.type" factoryName="com.jetbrains.cidr.embedded.openocd.conf.factory" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="myProject" TARGET_NAME="boot.elf" CONFIG_NAME="BOOT_DEBUG" version="1" RUN_TARGET_PROJECT_NAME="myProject" RUN_TARGET_NAME="boot.elf"> <configuration default="false" name="OCD Boot" type="com.jetbrains.cidr.embedded.openocd.conf.type" factoryName="com.jetbrains.cidr.embedded.openocd.conf.factory" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="myProject" TARGET_NAME="boot.elf" CONFIG_NAME="BOOT_DEBUG" version="1" RUN_TARGET_PROJECT_NAME="myProject" RUN_TARGET_NAME="boot.elf">
<openocd version="1" gdb-port="3333" telnet-port="4444" board-config="board/st_nucleo_g0.cfg" reset-type="RUN" download-type="UPDATED_ONLY"> <openocd version="1" gdb-port="3434" telnet-port="4343" board-config="C:\Users\Professional\CLionProjects\qrcode-reader-hardware\utils\board.cfg" reset-type="RUN" download-type="NONE">
<debugger kind="GDB" isBundled="true" /> <debugger kind="GDB" isBundled="true" />
</openocd> </openocd>
<method v="2"> <method v="2">
<option name="ToolBeforeRunTask" enabled="true" actionId="Tool_External Tools_DEBUGER_SELECT_SKUD" />
<option name="CLION.COMPOUND.BUILD" enabled="true" /> <option name="CLION.COMPOUND.BUILD" enabled="true" />
</method> </method>
</configuration> </configuration>

View File

@@ -117,7 +117,7 @@ void proximityMessureCompleted(void) {
VL6180_RangeData_t VL6180_Range; VL6180_RangeData_t VL6180_Range;
uint32_t waitAnswerFromReaderMs = 0; uint32_t waitAnswerFromReaderMs = 0;
#define MAX_WAIT_ANSWER_FROM_GM60 30000 #define MAX_WAIT_ANSWER_FROM_GM60 30000
#define MAX_WAIT_FOR_BOOT_COMMAND 10000 #define MAX_WAIT_FOR_BOOT_COMMAND 30000
#define DATA_TIMEOUT 500 #define DATA_TIMEOUT 500
uint32_t bootStartMs = 0; uint32_t bootStartMs = 0;
@@ -146,6 +146,8 @@ uint8_t uartTask(void) // return 0 if data received , otherwise return 1
{ {
uint8_t com = stringView[0]; uint8_t com = stringView[0];
if (com == ENTER_FIRMWARE_UPDATE) { if (com == ENTER_FIRMWARE_UPDATE) {
HAL_UART_Transmit_IT(bridge.getHuart1(), (uint8_t*) &uart1Buf[0], sizeof(sendCommand));
HAL_Delay(200);
HAL_UART_DeInit(bridge.getHuart1()); HAL_UART_DeInit(bridge.getHuart1());
BootComInit(); BootComInit();
zummerOff(); zummerOff();

View File

@@ -73,7 +73,7 @@
/** \brief Configure number of bytes in the host->target data packet. */ /** \brief Configure number of bytes in the host->target data packet. */
#define BOOT_COM_RS232_RX_MAX_DATA (129) #define BOOT_COM_RS232_RX_MAX_DATA (129)
/** \brief Select the desired UART peripheral as a zero based index. */ /** \brief Select the desired UART peripheral as a zero based index. */
#define BOOT_COM_RS232_CHANNEL_INDEX (1) #define BOOT_COM_RS232_CHANNEL_INDEX (0)
/**************************************************************************************** /****************************************************************************************

View File

@@ -11,8 +11,9 @@ Mcu.IP0=CRC
Mcu.IP1=NVIC Mcu.IP1=NVIC
Mcu.IP2=RCC Mcu.IP2=RCC
Mcu.IP3=SYS Mcu.IP3=SYS
Mcu.IP4=USART2 Mcu.IP4=USART1
Mcu.IPNb=5 Mcu.IP5=USART2
Mcu.IPNb=6
Mcu.Name=STM32G070CBTx Mcu.Name=STM32G070CBTx
Mcu.Package=LQFP48 Mcu.Package=LQFP48
Mcu.Pin0=PF0-OSC_IN (PF0) Mcu.Pin0=PF0-OSC_IN (PF0)
@@ -56,8 +57,10 @@ PA5.GPIO_Label=READER_EN
PA5.Locked=true PA5.Locked=true
PA5.Signal=GPIO_Output PA5.Signal=GPIO_Output
PB6.Locked=true PB6.Locked=true
PB6.Mode=Asynchronous
PB6.Signal=USART1_TX PB6.Signal=USART1_TX
PB7.Locked=true PB7.Locked=true
PB7.Mode=Asynchronous
PB7.Signal=USART1_RX PB7.Signal=USART1_RX
PF0-OSC_IN\ (PF0).Mode=HSE-External-Oscillator PF0-OSC_IN\ (PF0).Mode=HSE-External-Oscillator
PF0-OSC_IN\ (PF0).Signal=RCC_OSC_IN PF0-OSC_IN\ (PF0).Signal=RCC_OSC_IN
@@ -92,7 +95,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_USART2_UART_Init-USART2-false-LL-true,4-MX_CRC_Init-CRC-false-HAL-true ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_USART2_UART_Init-USART2-false-LL-true,4-MX_CRC_Init-CRC-false-HAL-true,5-MX_USART1_UART_Init-USART1-false-LL-true
RCC.ADCFreq_Value=64000000 RCC.ADCFreq_Value=64000000
RCC.AHBFreq_Value=64000000 RCC.AHBFreq_Value=64000000
RCC.APBFreq_Value=64000000 RCC.APBFreq_Value=64000000
@@ -120,6 +123,9 @@ RCC.USART1Freq_Value=64000000
RCC.USART2Freq_Value=64000000 RCC.USART2Freq_Value=64000000
RCC.VCOInputFreq_Value=16000000 RCC.VCOInputFreq_Value=16000000
RCC.VCOOutputFreq_Value=128000000 RCC.VCOOutputFreq_Value=128000000
USART1.BaudRate=9600
USART1.IPParameters=VirtualMode-Asynchronous,BaudRate
USART1.VirtualMode-Asynchronous=VM_ASYNC
USART2.BaudRate=9600 USART2.BaudRate=9600
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
USART2.VirtualMode-Asynchronous=VM_ASYNC USART2.VirtualMode-Asynchronous=VM_ASYNC

View File

@@ -36,6 +36,7 @@ extern "C" {
/* USER CODE END Private defines */ /* USER CODE END Private defines */
void MX_USART1_UART_Init(void);
void MX_USART2_UART_Init(void); void MX_USART2_UART_Init(void);
/* USER CODE BEGIN Prototypes */ /* USER CODE BEGIN Prototypes */

View File

@@ -26,6 +26,7 @@
/* CRC init function */ /* CRC init function */
void HAL_CRC_MspInit(CRC_HandleTypeDef* crcHandle) void HAL_CRC_MspInit(CRC_HandleTypeDef* crcHandle)
{ {

View File

@@ -39,8 +39,6 @@
* EVENT_OUT * EVENT_OUT
* EXTI * EXTI
PA11 [PA9] ------> I2C2_SCL PA11 [PA9] ------> I2C2_SCL
PB6 ------> USART1_TX
PB7 ------> USART1_RX
*/ */
void MX_GPIO_Init(void) void MX_GPIO_Init(void)
{ {
@@ -72,24 +70,6 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Alternate = LL_GPIO_AF_6; GPIO_InitStruct.Alternate = LL_GPIO_AF_6;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct); LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
} }
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */

View File

@@ -89,6 +89,7 @@ int main(void)
MX_GPIO_Init(); MX_GPIO_Init();
MX_USART2_UART_Init(); MX_USART2_UART_Init();
MX_CRC_Init(); MX_CRC_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
/* Initialize the bootloader application. */ /* Initialize the bootloader application. */
AppInit(); AppInit();

View File

@@ -24,6 +24,77 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
/* USART1 init function */
void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
LL_USART_InitTypeDef USART_InitStruct = {0};
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK1);
/* Peripheral clock enable */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
/**USART1 GPIO Configuration
PB6 ------> USART1_TX
PB7 ------> USART1_RX
*/
GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1;
USART_InitStruct.BaudRate = 9600;
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
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(USART1, &USART_InitStruct);
LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8);
LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8);
LL_USART_DisableFIFO(USART1);
LL_USART_ConfigAsyncMode(USART1);
/* USER CODE BEGIN WKUPType USART1 */
/* USER CODE END WKUPType USART1 */
LL_USART_Enable(USART1);
/* Polling USART1 initialisation */
while((!(LL_USART_IsActiveFlag_TEACK(USART1))) || (!(LL_USART_IsActiveFlag_REACK(USART1))))
{
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
/* USART2 init function */ /* USART2 init function */
void MX_USART2_UART_Init(void) void MX_USART2_UART_Init(void)

View File

@@ -42,7 +42,7 @@
* BOOT_BACKDOOR_ENTRY_TIMEOUT_MS to blt_conf.h with your desired backdoor * BOOT_BACKDOOR_ENTRY_TIMEOUT_MS to blt_conf.h with your desired backdoor
* open time in milliseconds. * open time in milliseconds.
*/ */
#define BOOT_BACKDOOR_ENTRY_TIMEOUT_MS (500) #define BOOT_BACKDOOR_ENTRY_TIMEOUT_MS (5000)
#endif #endif
#endif /* BOOT_BACKDOOR_HOOKS_ENABLE == 0 */ #endif /* BOOT_BACKDOOR_HOOKS_ENABLE == 0 */
@@ -168,6 +168,7 @@ void BackDoorCheck(void)
} }
} }
#endif #endif
} /*** end of BackDoorCheck ***/ } /*** end of BackDoorCheck ***/

View File

@@ -171,6 +171,7 @@ void XcpInit(void)
****************************************************************************************/ ****************************************************************************************/
blt_bool XcpIsConnected(void) blt_bool XcpIsConnected(void)
{ {
if (xcpInfo.connected == 0) if (xcpInfo.connected == 0)
{ {
return BLT_FALSE; return BLT_FALSE;

View File

@@ -1,4 +1,4 @@
adapter serial "\x34\x00\x48\x00\x0D\x00\x00\x59\x33\x4A\x53\x4E" adapter serial "48FF71066567495729231187"
# This is for all ST NUCLEO with any STM32F4. Known boards at the moment: # This is for all ST NUCLEO with any STM32F4. Known boards at the moment:
# STM32F401RET6 # STM32F401RET6

View File

@@ -3,10 +3,20 @@ $dir=$PSScriptRoot
$MyCommand="$dir"+"\stlink\st-info.exe --probe --hot-plug" $MyCommand="$dir"+"\stlink\st-info.exe --probe --hot-plug"
Invoke-Expression -Command $MyCommand | Out-String -OutVariable output Invoke-Expression -Command $MyCommand | Out-String -OutVariable output
$DevicesNum=$output.Substring($output.IndexOf("Found") + 7, 1) $DevicesNum=$output.Substring($output.IndexOf("Found") + 7, 1)
Write-Host -ForegroundColor Yellow -BackgroundColor Blue 'Do you wanna run the script N/Y'
$key=Read-Host
if ($key.ToUpper() -notmatch 'Y')
{
exit
}
if ($DevicesNum -eq 1) if ($DevicesNum -eq 1)
{ {
$serial=$output.Substring($output.Trim().IndexOf("serial") + 12, 24) $serial=$output.Substring($output.Trim().IndexOf("serial") + 12, 24)
} }
elseif ($DevicesNum -eq 0)
{
exit
}
else else
{ {
Write-Host -ForegroundColor Yellow -BackgroundColor Blue 'Press key which number of debugger you wanna use' Write-Host -ForegroundColor Yellow -BackgroundColor Blue 'Press key which number of debugger you wanna use'
@@ -24,7 +34,7 @@ $serial=$serial.ToCharArray()
$StringForCompare='adapter serial "' $StringForCompare='adapter serial "'
for ($i = 0; $i -lt $serial.Count; $i=$i+2) { for ($i = 0; $i -lt $serial.Count; $i=$i+2) {
$StringForCompare=$StringForCompare.Insert($StringForCompare.Length,"\x$($serial.Get($i))$($serial.Get($i+1))") $StringForCompare=$StringForCompare.Insert($StringForCompare.Length,"$($serial.Get($i))$($serial.Get($i+1))")
} }
$StringForCompare=$StringForCompare.Insert($StringForCompare.Length,'"') $StringForCompare=$StringForCompare.Insert($StringForCompare.Length,'"')
$Path = "$dir"+"/board.cfg" $Path = "$dir"+"/board.cfg"