stm32 examples revamp

This commit is contained in:
cpq committed 2026-05-22 15:39:25 +01:00
1 parent d4013e47f9
commit 21b9cdaef7
1577 files changed
+619 -842795

No files matched your search

@@ -0,0 +1,30 @@
# Portenta H7 Mongoose Integration
This guide explains how to bring up a production-grade Web UI dashboard on the
Portenta H7 board.
A pre-configured, ready-to-run project zip is available for download at
https://mongoose.ws.
To integrate the Web UI dashboard into an existing CubeMX project, or to create a
new project from scratch:
1. Configure the peripherals (described below).
2. Regenerate your project code and integrate Mongoose core by following
https://mongoose.ws/docs/guides/stm32-tcpip-stack/.
3. Add the Web UI dashboard by following
https://mongoose.ws/docs/guides/web-dashboard-guide/.
Note: to setup your WiFi login credentials, open the `wifi.c` file located in the
`Mongoose` directory and edit the `WIFI_NAME` and `WIFI_PASS` macros.
## Configure peripherals
An `.ioc` file is included in this directory for your reference. It was created
using the following steps:
- Open CubeMX. If you are starting a new project, select the STM32747XI
microcontroller and create a new project.
- In Clock Configuration, set the maximum clock frequency to 200 MHz.
- In Pinout & Configuration / Connectivity, enable USART1 in asynchronous mode.
Configure pins PA9 and PA10 for USART.
@@ -0,0 +1,7 @@
if(NOT EXISTS mbed/.git)
execute_process(COMMAND git clone --depth 1 --no-checkout -b extrapatches-6.17.0 https://github.com/arduino/mbed-os mbed)
endif()
execute_process(COMMAND git -C mbed sparse-checkout set targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/resources)
execute_process(COMMAND git -C mbed checkout)
file(TOUCH wiced_resource.h)
@@ -0,0 +1,5 @@
#pragma once
#define MG_ARCH MG_ARCH_CUBE
#define MG_ENABLE_DRIVER_CYW_SDIO 1
extern void wifi_setconfig(void *data);
#define MG_SET_WIFI_CONFIG(ifp, data) wifi_setconfig(data)
@@ -0,0 +1,406 @@
#MicroXplorer Configuration settings - do not modify
CAD.formats=
CAD.pinconfig=
CAD.provider=
CortexM4.IPs=BDMA,DMA,FATFS_M4\:I,FREERTOS_M4\:I,IWDG2\:I,MDMA,NVIC2\:I,RCC,USB_DEVICE_M4\:I,USB_HOST_M4\:I,WWDG2\:I,ADC1\:I,DCMI\:I,TIM3\:I,DEBUG,PDM2PCM_M4\:I,PWR,RESMGR_UTILITY,SYS_M4\:I,CORTEX_M4\:I,OPENAMP_M4\:I,VREFBUF,GPIO
CortexM7.IPs=BDMA\:I,DMA\:I,FATFS_M7\:I,FREERTOS_M7\:I,IWDG1\:I,MDMA\:I,NVIC1\:I,RCC\:I,USB_DEVICE_M7\:I,USB_HOST_M7\:I,WWDG1\:I,CORTEX_M7\:I,DEBUG\:I,PDM2PCM_M7\:I,PWR\:I,RESMGR_UTILITY\:I,SYS\:I,OPENAMP_M7\:I,VREFBUF\:I,GPIO\:I,RNG\:I,USART1\:I,SDMMC1\:I,MEMORYMAP\:I
CortexM7.Pins=PK5,PK6,PK7,PJ1,PJ5
File.Version=6
GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false
MMTAppReg1.MEMORYMAP.AppRegionName=RAM
MMTAppReg1.MEMORYMAP.ContextName=CortexM7
MMTAppReg1.MEMORYMAP.CoreName=ARM Cortex-M7
MMTAppReg1.MEMORYMAP.DefaultDataRegion=true
MMTAppReg1.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,DefaultDataRegion,ContextName,Name
MMTAppReg1.MEMORYMAP.Name=RAM
MMTAppReg1.MEMORYMAP.Size=131072
MMTAppReg1.MEMORYMAP.StartAddress=0x20000000
MMTAppReg10.MEMORYMAP.AppRegionName=M4 non Shared Region
MMTAppReg10.MEMORYMAP.ContextLink=reserved
MMTAppReg10.MEMORYMAP.ContextName=CortexM7
MMTAppReg10.MEMORYMAP.CoreName=ARM Cortex-M7
MMTAppReg10.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,MemType,ContextName,Name,ReservedRegion,ContextLink
MMTAppReg10.MEMORYMAP.MemType=ROM
MMTAppReg10.MEMORYMAP.Name=M4 non Shared Region
MMTAppReg10.MEMORYMAP.ReservedRegion=true
MMTAppReg10.MEMORYMAP.Size=1048576
MMTAppReg10.MEMORYMAP.StartAddress=0x08100000
MMTAppReg2.MEMORYMAP.AppRegionName=ITCMRAM
MMTAppReg2.MEMORYMAP.Cacheability=WTRA
MMTAppReg2.MEMORYMAP.ContextName=CortexM7
MMTAppReg2.MEMORYMAP.CoreName=ARM Cortex-M7
MMTAppReg2.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,ContextName,Name,Cacheability
MMTAppReg2.MEMORYMAP.Name=ITCMRAM
MMTAppReg2.MEMORYMAP.Size=65536
MMTAppReg2.MEMORYMAP.StartAddress=0x00000000
MMTAppReg3.MEMORYMAP.AppRegionName=RAM_D1
MMTAppReg3.MEMORYMAP.ContextLink=shared
MMTAppReg3.MEMORYMAP.ContextName=CortexM7
MMTAppReg3.MEMORYMAP.CoreName=ARM Cortex-M7
MMTAppReg3.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,ContextName,Name,ContextLink
MMTAppReg3.MEMORYMAP.Name=RAM_D1
MMTAppReg3.MEMORYMAP.Size=524288
MMTAppReg3.MEMORYMAP.StartAddress=0x24000000
MMTAppReg4.MEMORYMAP.AppRegionName=M7 non Shared Region
MMTAppReg4.MEMORYMAP.ContextLink=reserved
MMTAppReg4.MEMORYMAP.ContextName=CortexM4
MMTAppReg4.MEMORYMAP.CoreName=ARM Cortex-M4
MMTAppReg4.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,ContextName,Name,ReservedRegion,ContextLink
MMTAppReg4.MEMORYMAP.Name=M7 non Shared Region
MMTAppReg4.MEMORYMAP.ReservedRegion=true
MMTAppReg4.MEMORYMAP.Size=524288
MMTAppReg4.MEMORYMAP.StartAddress=0x24000000
MMTAppReg5.MEMORYMAP.AP=RO_priv_only
MMTAppReg5.MEMORYMAP.AppRegionName=FLASH
MMTAppReg5.MEMORYMAP.Cacheability=WTRA
MMTAppReg5.MEMORYMAP.ContextLink=shared
MMTAppReg5.MEMORYMAP.ContextName=CortexM7
MMTAppReg5.MEMORYMAP.CoreName=ARM Cortex-M7
MMTAppReg5.MEMORYMAP.DefaultCodeRegion=true
MMTAppReg5.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,MemType,ContextName,Name,AP,Cacheability,DefaultCodeRegion,ISRRegion,RootBootRegion,ContextLink
MMTAppReg5.MEMORYMAP.ISRRegion=true
MMTAppReg5.MEMORYMAP.MemType=ROM
MMTAppReg5.MEMORYMAP.Name=FLASH
MMTAppReg5.MEMORYMAP.RootBootRegion=true
MMTAppReg5.MEMORYMAP.Size=786432
MMTAppReg5.MEMORYMAP.StartAddress=0x08040000
MMTAppReg6.MEMORYMAP.AppRegionName=M7 non Shared Region
MMTAppReg6.MEMORYMAP.ContextLink=reserved
MMTAppReg6.MEMORYMAP.ContextName=CortexM4
MMTAppReg6.MEMORYMAP.CoreName=ARM Cortex-M4
MMTAppReg6.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,MemType,ContextName,Name,ReservedRegion,ContextLink
MMTAppReg6.MEMORYMAP.MemType=ROM
MMTAppReg6.MEMORYMAP.Name=M7 non Shared Region
MMTAppReg6.MEMORYMAP.ReservedRegion=true
MMTAppReg6.MEMORYMAP.Size=786432
MMTAppReg6.MEMORYMAP.StartAddress=0x8040000
MMTAppReg7.MEMORYMAP.AppRegionName=RAM
MMTAppReg7.MEMORYMAP.Cacheability=NonCacheable
MMTAppReg7.MEMORYMAP.ContextLink=shared
MMTAppReg7.MEMORYMAP.ContextName=CortexM4
MMTAppReg7.MEMORYMAP.CoreName=ARM Cortex-M4
MMTAppReg7.MEMORYMAP.DefaultDataRegion=true
MMTAppReg7.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,ContextName,Name,Cacheability,DefaultDataRegion,ContextLink
MMTAppReg7.MEMORYMAP.Name=RAM
MMTAppReg7.MEMORYMAP.Size=294912
MMTAppReg7.MEMORYMAP.StartAddress=0x10000000
MMTAppReg8.MEMORYMAP.AppRegionName=M4 non Shared Region
MMTAppReg8.MEMORYMAP.ContextLink=reserved
MMTAppReg8.MEMORYMAP.ContextName=CortexM7
MMTAppReg8.MEMORYMAP.CoreName=ARM Cortex-M7
MMTAppReg8.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,ContextName,Name,ReservedRegion,ContextLink
MMTAppReg8.MEMORYMAP.Name=M4 non Shared Region
MMTAppReg8.MEMORYMAP.ReservedRegion=true
MMTAppReg8.MEMORYMAP.Size=294912
MMTAppReg8.MEMORYMAP.StartAddress=0x10000000
MMTAppReg9.MEMORYMAP.AP=RO_priv_only
MMTAppReg9.MEMORYMAP.AppRegionName=FLASH
MMTAppReg9.MEMORYMAP.Cacheability=NonCacheable
MMTAppReg9.MEMORYMAP.ContextLink=shared
MMTAppReg9.MEMORYMAP.ContextName=CortexM4
MMTAppReg9.MEMORYMAP.CoreName=ARM Cortex-M4
MMTAppReg9.MEMORYMAP.DefaultCodeRegion=true
MMTAppReg9.MEMORYMAP.IPParameters=StartAddress,Size,CoreName,MemType,ContextName,Name,AP,Cacheability,DefaultCodeRegion,ISRRegion,RootBootRegion,ContextLink
MMTAppReg9.MEMORYMAP.ISRRegion=true
MMTAppReg9.MEMORYMAP.MemType=ROM
MMTAppReg9.MEMORYMAP.Name=FLASH
MMTAppReg9.MEMORYMAP.RootBootRegion=true
MMTAppReg9.MEMORYMAP.Size=1048576
MMTAppReg9.MEMORYMAP.StartAddress=0x08100000
MMTAppRegionsCount=10
MMTConfigApplied=false
MMTProjectManagerApplied=true
MMTSectionSuffix=
Mcu.CPN=STM32H747XIH6
Mcu.Context0=CortexM7
Mcu.Context1=CortexM4
Mcu.ContextNb=2
Mcu.Family=STM32H7
Mcu.IP0=CORTEX_M4
Mcu.IP1=CORTEX_M7
Mcu.IP2=MEMORYMAP
Mcu.IP3=NVIC1
Mcu.IP4=NVIC2
Mcu.IP5=RCC
Mcu.IP6=RNG
Mcu.IP7=SYS
Mcu.IP8=SYS_M4
Mcu.IP9=USART1
Mcu.IPNb=10
Mcu.Name=STM32H747XIHx
Mcu.Package=TFBGA240
Mcu.Pin0=PK5
Mcu.Pin1=PC10
Mcu.Pin10=PC8
Mcu.Pin11=PC9
Mcu.Pin12=PH0-OSC_IN (PH0)
Mcu.Pin13=PJ1
Mcu.Pin14=PJ5
Mcu.Pin15=VP_RNG_VS_RNG
Mcu.Pin16=VP_SYS_VS_Systick
Mcu.Pin17=VP_SYS_M4_VS_Systick
Mcu.Pin18=VP_MEMORYMAP_VS_MEMORYMAP
Mcu.Pin2=PC11
Mcu.Pin3=PC14-OSC32_IN (OSC32_IN)
Mcu.Pin4=PK6
Mcu.Pin5=PC12
Mcu.Pin6=PK7
Mcu.Pin7=PD2
Mcu.Pin8=PA10
Mcu.Pin9=PA9
Mcu.PinsNb=19
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32H747XIHx
MxCube.Version=6.17.0
MxDb.Version=DB.6.0.170
NVIC1.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC1.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC1.ForceEnableDMAVector=true
NVIC1.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC1.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC1.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC1.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC1.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC1.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC1.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false
NVIC1.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.ForceEnableDMAVector=true
NVIC2.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC2.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC2.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false
NVIC2.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA10.GPIOParameters=GPIO_Label,PinAttribute
PA10.GPIO_Label=USART1_RX
PA10.Locked=true
PA10.Mode=Asynchronous
PA10.PinAttribute=CortexM7
PA10.Signal=USART1_RX
PA9.GPIOParameters=GPIO_Label,PinAttribute
PA9.GPIO_Label=USART1_TX
PA9.Locked=true
PA9.Mode=Asynchronous
PA9.PinAttribute=CortexM7
PA9.Signal=USART1_TX
PC10.GPIOParameters=GPIO_PuPd,GPIO_Label,PinAttribute
PC10.GPIO_Label=SDIO_D2
PC10.GPIO_PuPd=GPIO_PULLUP
PC10.Locked=true
PC10.PinAttribute=CortexM7
PC10.Signal=SDMMC1_D2
PC11.GPIOParameters=GPIO_PuPd,GPIO_Label,PinAttribute
PC11.GPIO_Label=SDIO_D3
PC11.GPIO_PuPd=GPIO_PULLUP
PC11.Locked=true
PC11.PinAttribute=CortexM7
PC11.Signal=SDMMC1_D3
PC12.GPIOParameters=GPIO_PuPd,GPIO_Label,PinAttribute
PC12.GPIO_Label=SDIO_CLK
PC12.GPIO_PuPd=GPIO_PULLUP
PC12.Locked=true
PC12.PinAttribute=CortexM7
PC12.Signal=SDMMC1_CK
PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label,PinAttribute
PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=OSC32_IN
PC14-OSC32_IN\ (OSC32_IN).Locked=true
PC14-OSC32_IN\ (OSC32_IN).Mode=LSE-External-Clock-Source
PC14-OSC32_IN\ (OSC32_IN).PinAttribute=CortexM7
PC14-OSC32_IN\ (OSC32_IN).Signal=RCC_OSC32_IN
PC8.GPIOParameters=GPIO_PuPd,GPIO_Label,PinAttribute
PC8.GPIO_Label=SDIO_D0
PC8.GPIO_PuPd=GPIO_PULLUP
PC8.Locked=true
PC8.PinAttribute=CortexM7
PC8.Signal=SDMMC1_D0
PC9.GPIOParameters=GPIO_PuPd,GPIO_Label,PinAttribute
PC9.GPIO_Label=SDIO_D1
PC9.GPIO_PuPd=GPIO_PULLUP
PC9.Locked=true
PC9.PinAttribute=CortexM7
PC9.Signal=SDMMC1_D1
PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,PinAttribute
PD2.GPIO_Label=SDIO_MMC
PD2.GPIO_PuPd=GPIO_PULLUP
PD2.Locked=true
PD2.PinAttribute=CortexM7
PD2.Signal=SDMMC1_CMD
PH0-OSC_IN\ (PH0).GPIOParameters=GPIO_Label,PinAttribute
PH0-OSC_IN\ (PH0).GPIO_Label=OSC25M_IN
PH0-OSC_IN\ (PH0).Locked=true
PH0-OSC_IN\ (PH0).Mode=HSE-External-Clock-Source
PH0-OSC_IN\ (PH0).PinAttribute=Free
PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN
PJ1.ContextOwner=CortexM7
PJ1.GPIOParameters=GPIO_Label,PinAttribute
PJ1.GPIO_Label=PWR
PJ1.Locked=true
PJ1.PinAttribute=CortexM7
PJ1.Signal=GPIO_Output
PJ5.ContextOwner=CortexM7
PJ5.GPIOParameters=GPIO_Label,PinAttribute
PJ5.GPIO_Label=WAKE
PJ5.Locked=true
PJ5.PinAttribute=CortexM7
PJ5.Signal=GPIO_Input
PK5.ContextOwner=CortexM7
PK5.GPIOParameters=PinState,GPIO_Label,PinAttribute
PK5.GPIO_Label=LED R
PK5.Locked=true
PK5.PinAttribute=CortexM7
PK5.PinState=GPIO_PIN_SET
PK5.Signal=GPIO_Output
PK6.ContextOwner=CortexM7
PK6.GPIOParameters=PinState,GPIO_Label,PinAttribute
PK6.GPIO_Label=LED G
PK6.Locked=true
PK6.PinAttribute=CortexM7
PK6.PinState=GPIO_PIN_SET
PK6.Signal=GPIO_Output
PK7.ContextOwner=CortexM7
PK7.GPIOParameters=PinState,GPIO_Label,PinAttribute
PK7.GPIO_Label=LED B
PK7.Locked=true
PK7.PinAttribute=CortexM7
PK7.PinState=GPIO_PIN_SET
PK7.Signal=GPIO_Output
PinOutPanel.CurrentBGAView=Top
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false
ProjectManager.BootMode=boot0
ProjectManager.CompilerLinker=GCC
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
ProjectManager.CoupleFile=false
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32H747XIHx
ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.13.0
ProjectManager.FreePins=false
ProjectManager.FreePinsContext=CortexM7
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=M4-0x200,M7-0x10000
ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=1
ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=STM32CubeIDE
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=portenta_h7.ioc
ProjectManager.ProjectName=portenta_h7
ProjectManager.ProjectStructure=M7\:CortexM7 Project\:true;M4\:CortexM4 Project\:true;
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=M4-0x400,M7-0x2000
ProjectManager.TargetToolchain=CMake
ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false-CortexM7,2-MX_GPIO_Init-GPIO-false-HAL-true-CortexM7,3-MX_USART1_UART_Init-USART1-false-HAL-true-CortexM7,4-MX_RNG_Init-RNG-false-HAL-true-CortexM7,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true-CortexM7,0-MX_CORTEX_M4_Init-CORTEX_M4-false-HAL-true-CortexM4
RCC.ADCFreq_Value=80000000
RCC.AHB12Freq_Value=200000000
RCC.AHB4Freq_Value=200000000
RCC.APB1Freq_Value=100000000
RCC.APB2Freq_Value=100000000
RCC.APB3Freq_Value=100000000
RCC.APB4Freq_Value=100000000
RCC.AXIClockFreq_Value=200000000
RCC.CECFreq_Value=32000
RCC.CKPERFreq_Value=64000000
RCC.CPU2Freq_Value=200000000
RCC.CPU2SystikFreq_Value=200000000
RCC.CortexFreq_Value=400000000
RCC.CpuClockFreq_Value=400000000
RCC.D1CPREFreq_Value=400000000
RCC.D1PPRE=RCC_APB3_DIV2
RCC.D2PPRE1=RCC_APB1_DIV2
RCC.D2PPRE2=RCC_APB2_DIV2
RCC.D3PPRE=RCC_APB4_DIV2
RCC.DFSDMACLkFreq_Value=200000000
RCC.DFSDMFreq_Value=100000000
RCC.DIVM1=4
RCC.DIVM2=4
RCC.DIVN1=50
RCC.DIVN2=10
RCC.DIVP1Freq_Value=400000000
RCC.DIVP2Freq_Value=80000000
RCC.DIVP3Freq_Value=129000000
RCC.DIVQ1=4
RCC.DIVQ1Freq_Value=200000000
RCC.DIVQ2Freq_Value=80000000
RCC.DIVQ3Freq_Value=129000000
RCC.DIVR1Freq_Value=400000000
RCC.DIVR2Freq_Value=80000000
RCC.DIVR3Freq_Value=129000000
RCC.DSIFreq_Value=62500000
RCC.DSITXEscFreq_Value=15625000
RCC.FDCANFreq_Value=200000000
RCC.FMCFreq_Value=200000000
RCC.FamilyName=M
RCC.HCLK3ClockFreq_Value=200000000
RCC.HCLKFreq_Value=200000000
RCC.HPRE=RCC_HCLK_DIV2
RCC.HRTIMFreq_Value=200000000
RCC.I2C123Freq_Value=100000000
RCC.I2C4Freq_Value=100000000
RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CPU2Freq_Value,CPU2SystikFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,DSIFreq_Value,DSITXEscFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLLDSIVCOFreq_Value,PLLFRACN,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,SupplySource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value
RCC.LPTIM1Freq_Value=100000000
RCC.LPTIM2Freq_Value=100000000
RCC.LPTIM345Freq_Value=100000000
RCC.LPUART1Freq_Value=100000000
RCC.LTDCFreq_Value=129000000
RCC.MCO1PinFreq_Value=64000000
RCC.MCO2PinFreq_Value=400000000
RCC.PLL2FRACN=0
RCC.PLLDSIVCOFreq_Value=1000000000
RCC.PLLFRACN=0
RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE1
RCC.QSPIFreq_Value=200000000
RCC.RNGFreq_Value=48000000
RCC.RTCFreq_Value=32000
RCC.SAI1Freq_Value=200000000
RCC.SAI23Freq_Value=200000000
RCC.SAI4AFreq_Value=200000000
RCC.SAI4BFreq_Value=200000000
RCC.SDMMCFreq_Value=200000000
RCC.SPDIFRXFreq_Value=200000000
RCC.SPI123Freq_Value=200000000
RCC.SPI45Freq_Value=100000000
RCC.SPI6Freq_Value=100000000
RCC.SWPMI1Freq_Value=100000000
RCC.SYSCLKFreq_VALUE=400000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.SupplySource=PWR_DIRECT_SMPS_SUPPLY
RCC.Tim1OutputFreq_Value=200000000
RCC.Tim2OutputFreq_Value=200000000
RCC.TraceFreq_Value=64000000
RCC.USART16Freq_Value=100000000
RCC.USART234578Freq_Value=100000000
RCC.USBFreq_Value=200000000
RCC.VCO1OutputFreq_Value=800000000
RCC.VCO2OutputFreq_Value=160000000
RCC.VCO3OutputFreq_Value=258000000
RCC.VCOInput1Freq_Value=16000000
RCC.VCOInput2Freq_Value=16000000
RCC.VCOInput3Freq_Value=2000000
USART1.IPParameters=VirtualMode-Asynchronous
USART1.VirtualMode-Asynchronous=VM_ASYNC
VP_MEMORYMAP_VS_MEMORYMAP.Mode=CurAppReg
VP_MEMORYMAP_VS_MEMORYMAP.Signal=MEMORYMAP_VS_MEMORYMAP
VP_RNG_VS_RNG.Mode=RNG_Activate
VP_RNG_VS_RNG.Signal=RNG_VS_RNG
VP_SYS_M4_VS_Systick.Mode=SysTick
VP_SYS_M4_VS_Systick.Signal=SYS_M4_VS_Systick
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
board=STM32H747I-DISCO
boardIOC=true
+153
View File
@@ -0,0 +1,153 @@
#include "mongoose.h"
#include "main.h"
typedef enum {RESOURCE_IN_MEMORY,RESOURCE_IN_EXTERNAL_STORAGE} resource_location_t;
typedef struct {resource_location_t l;unsigned long sz;union{struct {unsigned long o;const char *f;}fs;struct {const char *m;}mem;}val;} resource_hnd_t;
#include "resources/firmware/COMPONENT_4343W_FS/4343WA1_clm_blob.c"
#include "resources/firmware/COMPONENT_4343W_FS/4343WA1_bin.c"
#include "resources/nvram/wifi_nvram_image.h"
#ifndef WIFI_NAME
#define WIFI_NAME ""
#endif
#ifndef WIFI_PASS
#define WIFI_PASS ""
#endif
#ifndef WIFI_AP_NAME
#define WIFI_AP_NAME "Mongoose"
#endif
#ifndef WIFI_AP_PASS
#define WIFI_AP_PASS "mongoose"
#endif
#ifndef ENABLE_WIFI_AP
#define ENABLE_WIFI_AP 0
#endif
// - 58.4 Table 473
// - 58.5.8 AHB bw >= 3x SDMMC bus bw; Table 492; SD HS => AHB >= ~20MHz
// - SDIO 2.0 section 3.1
static inline void sdmmc_set_ds(void) { // NO FLOW CONTROL ??? REALLY ??? *******************************
MG_SET_BITS(SDMMC1->CLKCR, (1 << 17) | 0x3ff, (1 << 14) | ((200000000 / (2 * 25000000)) & 0x3ff)); // 4-bit bus, 25MHz
}
static inline void sdmmc_set_hs(void) { // mbed enables flow control... AIROC does not
MG_SET_BITS(SDMMC1->CLKCR, 0x3ff, (1 << 17) | (1 << 14) | ((200000000 / (2 * 50000000)) & 0x3ff)); // hw flow control, 4-bit bus, 50MHz
}
static inline void sdmmc_init(void) {
RCC->AHB3RSTR |= MG_BIT(16); // Reset SDIO block
RCC->AHB3RSTR &= ~MG_BIT(16);
RCC->D1CCIPR &= ~MG_BIT(16); // 9.7.18, use PLL1Q
RCC->AHB3ENR |= MG_BIT(16); // Enable SDIO clock
// SDIO pins initialized by Cube; Portenta H7 doesn't pull-up the SDIO bus
// 1-bit bus, rising edge, clock always on, no flow control, 400KHz
SDMMC1->CLKCR = (200000000 / (2 * 400000)) & 0x3ff;
SDMMC1->POWER |= 3 << 0; // SDMMC_POWER_PWRCTRL
SDMMC1->DCTRL = MG_BIT(10); // Read Wait control by stopping SDMMCCLK
// wait 74 clocks (~200us) before accessing the "card"
}
static inline bool sdmmc_transact(uint8_t cmd, uint32_t arg, uint32_t *resp) {
unsigned int wresp = (resp != NULL) ? 1 : 0; // 58.10.4: 2-bit; cmds used
uint32_t cmdr = MG_BIT(12) | (wresp << 8) | ((cmd & 0x3f) << 0); // CPSMEN
SDMMC1->ARG = arg;
MG_SET_BITS(SDMMC1->CMD, 0x00011f3f /* CMDSUSPEND CPSMEN WAITPEND WAITINT WAITRESP CMD */, cmdr);
if (wresp == 0) {
while ((SDMMC1->STA & SDMMC_STA_CMDSENT) == 0) (void)0;
SDMMC1->ICR = 0x002000C5; // BUSYD0END CMDSENT CMDREND CTIMEOUT CCRCFAIL
return true;
}
//while ((SDMMC1->STA & 0x00200045 /*BUSYD0END CMDREND CTIMEOUT CCRCFAIL*/) == 0 || SDMMC1->STA & SDMMC_STA_CPSMACT) spin(1);
while (SDMMC1->STA & SDMMC_STA_CPSMACT) (void)0;
bool res = (SDMMC1->STA & 0x00200005 /*BUSYD0END CTIMEOUT CCRCFAIL*/) == 0;
SDMMC1->ICR = 0x002000C5; // BUSYD0END CMDSENT CMDREND CTIMEOUT CCRCFAIL
*resp = SDMMC1->RESP1;
if (!res || SDMMC1->RESPCMD != cmd) return false;
return true;
}
static inline unsigned int _log2(uint16_t x) {
unsigned int i = 0;
while (x != 0) x = ((uint16_t)x) >> 1, ++i;
return i - 1;
}
static inline bool sdmmc_transfer(bool write, uint32_t arg, uint16_t blksz, uint32_t *data, uint32_t length, uint32_t *resp) {
uint32_t cmdr = MG_BIT(12) | (1 << 8) | (53 << 0); // CPSMEN WRESP CMD=53
bool bmode = (blksz != 0);
uint8_t dblksz = bmode ? (uint8_t)_log2(blksz) : 0;
uint32_t dctrlr = (dblksz << 4) | (bmode ? (0 << 2) : (1 << 2)) | (write ? 0 : MG_BIT(1)); // DBLOCKSIZE=f(blksz) DTMODE=f(bmode) DTDIR=!write !DTEN
SDMMC1->DCTRL = SDMMC_DCTRL_RWMOD;
SDMMC1->IDMACTRL = SDMMC_IDMA_IDMAEN; // single buffer
SDMMC1->IDMABASE0 = (uint32_t)data;
SDMMC1->DTIMER = (uint32_t) 50000000; // 58.10.7, set for 1 sec @50MHz (2 secs @25MHz)
SDMMC1->DLEN = length; // 58.10.8 call with a multiple of blksz (we do)
MG_SET_BITS(SDMMC1->DCTRL, 0xff /* DBLOCKSIZE DTMODE DTDIR DTEN */, dctrlr);
SDMMC1->CMD = SDMMC_CMD_CMDTRANS; // CPSM will perform a data transfer
SDMMC1->ARG = arg;
SDMMC1->CMD |= cmdr; // other flags cleared above
while ((SDMMC1->STA & 0x0020003f) == 0 && SDMMC1->STA & SDMMC_STA_DPSMACT)
(void) 0; // incorrect "card" usage will stall here
bool res = (SDMMC1->STA & 0x0020003f /* BUSYD0END RXOVERR TXUNDERR DTIMEOUT CTIMEOUT DCRCFAIL CCRCFAIL */) == 0;
SDMMC1->CMD = 0;
SDMMC1->DLEN = 0;
SDMMC1->IDMACTRL = 0;
SDMMC1->ICR = (uint32_t) ~0; // clear all flags
*resp = SDMMC1->RESP1;
SDMMC1->DCTRL = SDMMC_DCTRL_RWMOD;
if (!res || SDMMC1->RESPCMD != 53) return false;
return true;
}
void hwspecific_sdio_init(void) {
HAL_GPIO_WritePin(PWR_GPIO_Port, PWR_Pin, 0);
mg_delayms(100);
sdmmc_init();
mg_delayms(1);
HAL_GPIO_WritePin(PWR_GPIO_Port, PWR_Pin, 1);
mg_delayms(50);
}
void hwspecific_sdio_config(void *sdio, uint8_t cfg) {
(void) sdio;
if (cfg == 0) return sdmmc_set_ds();
if (cfg == 1) return sdmmc_set_hs();
}
bool hwspecific_sdio_txn(void *sdio, uint8_t cmd, uint32_t arg, uint32_t *resp) {
(void) sdio;
return sdmmc_transact(cmd, arg, resp);
}
bool hwspecific_sdio_xfr(void *sdio, bool write, uint32_t arg, uint16_t blksz, uint32_t *data, uint32_t len, uint32_t *resp){
(void) sdio;
return sdmmc_transfer(write, arg, blksz, data, len, resp);
}
static const struct mg_tcpip_sdio sdio = {NULL, hwspecific_sdio_config, hwspecific_sdio_txn, hwspecific_sdio_xfr};
static const struct mg_tcpip_driver_cyw_firmware fw = {
(const uint8_t *)wifi_firmware_image_data, (size_t)sizeof(wifi_firmware_image_data),
(const uint8_t *)wifi_nvram_image, (size_t)sizeof(wifi_nvram_image),
(const uint8_t *)wifi_firmware_clm_blob_image_data, (size_t)sizeof(wifi_firmware_clm_blob_image_data)};
void wifi_setconfig(void *data) {
struct mg_tcpip_driver_cyw_data *d = (struct mg_tcpip_driver_cyw_data *) data;
d->bus = (struct mg_tcpip_sdio *) &sdio;
d->fw = (struct mg_tcpip_driver_cyw_firmware *)&fw;
d->wifi.ssid = WIFI_NAME;
d->wifi.pass = WIFI_PASS;
d->wifi.apssid = WIFI_AP_NAME;
d->wifi.appass = WIFI_AP_PASS;
d->wifi.apip = MG_IPV4(192, 168, 111, 1);
d->wifi.apmask = MG_IPV4(255, 255, 255, 0);
d->wifi.security = 0;
d->wifi.apsecurity = 0;
d->wifi.apchannel = 10;
d->wifi.apmode = ENABLE_WIFI_AP;
d->hs = false;
}