[feat][examples/usb] add usb msc flash and ota demo

This commit is contained in:
jzlv 2021-09-26 15:11:25 +08:00
parent bec13de776
commit 5b50669a14
7 changed files with 1136 additions and 0 deletions

View file

@ -0,0 +1,9 @@
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
set(TARGET_REQUIRED_LIBS usb_stack fatfs)
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb)
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c ${BSP_COMMON_DIR}/fatfs/fatfs_usb.c ${BSP_COMMON_DIR}/fatfs/fatfs_errorcode.c)
list(APPEND GLOBAL_C_FLAGS -DFF_MAX_SS=4096)
set(mains main.c)
generate_bin()

View file

@ -0,0 +1,741 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project Name="usb_msc_flash" Version="1" Language="C">
<Description>CPU: RV32IMAFC
Chip: bl70x
Board: bl70x_iot
</Description>
<Dependencies Name="Debug"/>
<VirtualDirectory Name="app">
<File Name="../main.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="chip">
<VirtualDirectory Name="riscv">
<File Name="../../../../drivers/bl702_driver/startup/interrupt.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/startup/system_bl702.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="startup">
<File Name="../../../../drivers/bl702_driver/startup/GCC/entry.S">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/startup/GCC/start_load.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="hal">
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_acomp.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_adc.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_boot2.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_cam.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_clock.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_common.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_dma.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_emac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_flash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_gpio.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2c.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_i2s.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_keyscan.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mjpeg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_mtimer.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pm.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_pwm.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_qdec.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_rtc.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_aes.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_dsa.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_ecdsa.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_sec_hash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_spi.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_timer.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_uart.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_usb.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/hal_drv/src/hal_wdt.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="std">
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_acomp.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_adc.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_aon.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_cam.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_clock.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_dma.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ef_ctrl.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_emac.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_glb.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_hbn.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2c_gpio_sim.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_i2s.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_ir.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_common.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_kys.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_l1c.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_mjpeg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pds.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_psram.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_pwm.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_qdec.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_romapi.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_dbg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sec_eng.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_cfg_ext.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sf_ctrl.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_sflash_ext.c" ExcludeProjConfig="">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_spi.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_timer.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_uart.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_usb.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash.c">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/std_drv/src/bl702_xip_sflash_ext.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="bsp">
<VirtualDirectory Name="board">
<File Name="../../../../bsp/board/bl702/board.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="bsp_common">
<File Name="../../../../bsp/bsp_common/platform/bflb_platform.c">
<FileOption/>
</File>
<File Name="../../../../bsp/bsp_common/platform/syscalls.c">
<FileOption/>
</File>
<File Name="../../../../bsp/bsp_common/usb/uart_interface.c">
<FileOption/>
</File>
<File Name="../../../../bsp/bsp_common/usb/usb_dc.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="common">
<File Name="../../../../common/device/drv_device.c">
<FileOption/>
</File>
<File Name="../../../../common/memheap/drv_mmheap.c">
<FileOption/>
</File>
<File Name="../../../../common/ring_buffer/ring_buffer.c">
<FileOption/>
</File>
<File Name="../../../../common/soft_crc/softcrc.c">
<FileOption/>
</File>
<File Name="../../../../common/misc/misc.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="script">
<File Name="../../../../tools/openocd/bl70x_gdb.init">
<FileOption/>
</File>
<File Name="../../../../drivers/bl702_driver/regs/bl70x_reg.svc">
<FileOption/>
</File>
</VirtualDirectory>
<MonitorProgress>
<DebugLaunch>154</DebugLaunch>
<FlashOperate>104</FlashOperate>
</MonitorProgress>
<VirtualDirectory Name="components">
<VirtualDirectory Name="fatfs">
<File Name="../../../../components/fatfs/diskio.c">
<FileOption/>
</File>
<File Name="../../../../components/fatfs/ff.c">
<FileOption/>
</File>
<File Name="../../../../components/fatfs/ffsystem.c">
<FileOption/>
</File>
<File Name="../../../../components/fatfs/ffunicode.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="shell">
<File Name="../../../../components/shell/shell.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="usb_stack">
<VirtualDirectory Name="class">
<VirtualDirectory Name="cdc">
<File Name="../../../../components/usb_stack/class/cdc/usbd_cdc.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="hid">
<File Name="../../../../components/usb_stack/class/hid/usbd_hid.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="msc">
<File Name="../../../../components/usb_stack/class/msc/usbd_msc.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="core">
<File Name="../../../../components/usb_stack/core/usbd_core.c">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
</VirtualDirectory>
<Dependencies Name="BuildSet"/>
<DebugSessions>
<watchExpressions/>
<memoryExpressions>;;;</memoryExpressions>
<statistics>;;MHZ;</statistics>
<peripheralTabs>
<Tab disFormat="Hex">glb</Tab>
<Tab disFormat="Hex">uart</Tab>
</peripheralTabs>
<WatchDisplayFormat>1</WatchDisplayFormat>
<LocalDisplayFormat>1</LocalDisplayFormat>
<debugLayout/>
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
</DebugSessions>
<DebugSessions>
<watchExpressions/>
<memoryExpressions>;;;</memoryExpressions>
<statistics>;;MHZ;</statistics>
<peripheralTabs>
<Tab disFormat="Hex">glb</Tab>
<Tab disFormat="Hex">uart</Tab>
</peripheralTabs>
<WatchDisplayFormat>1</WatchDisplayFormat>
<LocalDisplayFormat>1</LocalDisplayFormat>
<debugLayout/>
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
</DebugSessions>
<Dependencies Name="CK_Link_Debug"/>
<Dependencies Name="OpenOCD_Debug"/>
<BuildConfigs>
<BuildConfig Name="OpenOCD_Debug">
<Target>
<ROMBank Selected="1">
<ROM1>
<InUse>no</InUse>
<Start>0x23000000</Start>
<Size>0x100000</Size>
</ROM1>
<ROM2>
<InUse>no</InUse>
<Start>0x22014000</Start>
<Size>0x4000</Size>
</ROM2>
<ROM3>
<InUse>no</InUse>
<Start>0x42018000</Start>
<Size>0x8000</Size>
</ROM3>
<ROM4>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM4>
<ROM5>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM5>
</ROMBank>
<RAMBank>
<RAM1>
<InUse>yes</InUse>
<Start>0x42020000</Start>
<Size>0xc000</Size>
<Init>yes</Init>
</RAM1>
<RAM2>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM2>
<RAM3>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM3>
<RAM4>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM4>
<RAM5>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM5>
</RAMBank>
<CPU>rv32imafc</CPU>
<UseMiniLib>yes</UseMiniLib>
<Endian>little</Endian>
<UseHardFloat>no</UseHardFloat>
<UseEnhancedLRW>no</UseEnhancedLRW>
<UseContinueBuild>no</UseContinueBuild>
<UseSemiHost>no</UseSemiHost>
</Target>
<Output>
<OutputName>$(ProjectName)</OutputName>
<Type>Executable</Type>
<CreateHexFile>no</CreateHexFile>
<CreateBinFile>yes</CreateBinFile>
<Preprocessor>no</Preprocessor>
<Disassmeble>yes</Disassmeble>
<CallGraph>no</CallGraph>
<Map>yes</Map>
</Output>
<User>
<BeforeCompile>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeCompile>
<BeforeMake>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeMake>
<AfterMake>
<RunUserProg>no</RunUserProg>
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --interface=openocd --firmware="$(ProjectPath)/Obj/$(ProjectName).bin" </UserProgName>
</AfterMake>
</User>
<Compiler>
<Define>ARCH_RISCV;BFLB_USE_HAL_DRIVER;BFLB_USE_ROM_DRIVER;bl706_iot</Define>
<Undefine/>
<Optim>Optimize more (-O2)</Optim>
<DebugLevel>Default (-g)</DebugLevel>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc</IncludePath>
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4 -std=c99</OtherFlags>
<Verbose>no</Verbose>
<Ansi>no</Ansi>
<Syntax>no</Syntax>
<Pedantic>no</Pedantic>
<PedanticErr>no</PedanticErr>
<InhibitWarn>no</InhibitWarn>
<AllWarn>yes</AllWarn>
<WarnErr>no</WarnErr>
<OneElfS>yes</OneElfS>
<Fstrict>no</Fstrict>
</Compiler>
<Asm>
<Define/>
<Undefine/>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
<OtherFlags/>
<DebugLevel>gdwarf2</DebugLevel>
</Asm>
<Linker>
<Garbage>yes</Garbage>
<Garbage2>yes</Garbage2>
<LDFile>$(ProjectPath)../../../../drivers/bl702_driver/bl702_flash.ld</LDFile>
<LibName>c</LibName>
<LibPath/>
<OtherFlags>--specs=nano.specs</OtherFlags>
<AutoLDFile>no</AutoLDFile>
<LinkType/>
</Linker>
<Debug>
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
<Connector>OpenOCD</Connector>
<StopAt>yes</StopAt>
<StopAtText>main</StopAtText>
<InitFile/>
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
<AutoRun>yes</AutoRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>23000000</SoftResetVal>
<ResetAfterLoad>no</ResetAfterLoad>
<Dumpcore>no</Dumpcore>
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
<ConfigICE>
<IP>localhost</IP>
<PORT>1025</PORT>
<CPUNumber>0</CPUNumber>
<Clock>2000</Clock>
<Delay>10</Delay>
<WaitReset>50</WaitReset>
<DDC>yes</DDC>
<TRST>no</TRST>
<DebugPrint>no</DebugPrint>
<Connect>Normal</Connect>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>21000000</SoftResetVal>
<RTOSType>Bare Metal</RTOSType>
<DownloadToFlash>yes</DownloadToFlash>
<ResetAfterConnect>yes</ResetAfterConnect>
<GDBName/>
<GDBServerType>Local</GDBServerType>
<OtherFlags>-arch riscv</OtherFlags>
</ConfigICE>
<ConfigSIM>
<SIMTarget/>
<OtherFlags/>
<NoGraphic>yes</NoGraphic>
<Log>no</Log>
<SimTrace>no</SimTrace>
</ConfigSIM>
<ConfigOpenOCD>
<OpenOCDExecutablePath>openocd-hifive</OpenOCDExecutablePath>
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
<OpenOCDTclPort>6666</OpenOCDTclPort>
<OpenOCDConfigOptions>-f ../../../../tools/openocd/if_rv_dbg_plus.cfg -f ../../../../tools/openocd/tgt_702.cfg</OpenOCDConfigOptions>
</ConfigOpenOCD>
</Debug>
<Flash>
<InitFile/>
<Erase>Erase Sectors</Erase>
<Algorithms Path="">bl70x_flasher.elf</Algorithms>
<Program>yes</Program>
<Verify>yes</Verify>
<ResetAndRun>no</ResetAndRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal/>
<External>no</External>
<Command/>
<Arguments/>
</Flash>
</BuildConfig>
<BuildConfig Name="CK_Link_Debug">
<Target>
<ROMBank Selected="1">
<ROM1>
<InUse>no</InUse>
<Start>0x23000000</Start>
<Size>0x100000</Size>
</ROM1>
<ROM2>
<InUse>no</InUse>
<Start>0x22014000</Start>
<Size>0x4000</Size>
</ROM2>
<ROM3>
<InUse>no</InUse>
<Start>0x42018000</Start>
<Size>0x8000</Size>
</ROM3>
<ROM4>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM4>
<ROM5>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM5>
</ROMBank>
<RAMBank>
<RAM1>
<InUse>yes</InUse>
<Start>0x42020000</Start>
<Size>0xc000</Size>
<Init>yes</Init>
</RAM1>
<RAM2>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM2>
<RAM3>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM3>
<RAM4>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM4>
<RAM5>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM5>
</RAMBank>
<CPU>rv32imafc</CPU>
<UseMiniLib>yes</UseMiniLib>
<Endian>little</Endian>
<UseHardFloat>no</UseHardFloat>
<UseEnhancedLRW>no</UseEnhancedLRW>
<UseContinueBuild>no</UseContinueBuild>
<UseSemiHost>no</UseSemiHost>
</Target>
<Output>
<OutputName>$(ProjectName)</OutputName>
<Type>Executable</Type>
<CreateHexFile>no</CreateHexFile>
<CreateBinFile>yes</CreateBinFile>
<Preprocessor>no</Preprocessor>
<Disassmeble>yes</Disassmeble>
<CallGraph>no</CallGraph>
<Map>yes</Map>
</Output>
<User>
<BeforeCompile>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeCompile>
<BeforeMake>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeMake>
<AfterMake>
<RunUserProg>no</RunUserProg>
<UserProgName>$(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --interface=openocd --firmware="$(ProjectPath)/Obj/$(ProjectName).bin" </UserProgName>
</AfterMake>
</User>
<Compiler>
<Define>ARCH_RISCV;BFLB_USE_HAL_DRIVER;BFLB_USE_ROM_DRIVER;bl706_iot</Define>
<Undefine/>
<Optim>Optimize more (-O2)</Optim>
<DebugLevel>Default (-g)</DebugLevel>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/usb;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
<OtherFlags>-fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4 -std=c99</OtherFlags>
<Verbose>no</Verbose>
<Ansi>no</Ansi>
<Syntax>no</Syntax>
<Pedantic>no</Pedantic>
<PedanticErr>no</PedanticErr>
<InhibitWarn>no</InhibitWarn>
<AllWarn>yes</AllWarn>
<WarnErr>no</WarnErr>
<OneElfS>yes</OneElfS>
<Fstrict>no</Fstrict>
</Compiler>
<Asm>
<Define/>
<Undefine/>
<IncludePath>$(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../bsp/bsp_common/usb;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc</IncludePath>
<OtherFlags/>
<DebugLevel>gdwarf2</DebugLevel>
</Asm>
<Linker>
<Garbage>yes</Garbage>
<Garbage2>yes</Garbage2>
<LDFile>$(ProjectPath)../../../../drivers/bl702_driver/bl702_flash.ld</LDFile>
<LibName>c</LibName>
<LibPath/>
<OtherFlags>--specs=nano.specs</OtherFlags>
<AutoLDFile>no</AutoLDFile>
<LinkType/>
</Linker>
<Debug>
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
<Connector>ICE</Connector>
<StopAt>yes</StopAt>
<StopAtText>main</StopAtText>
<InitFile/>
<AfterLoadFile>$(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init</AfterLoadFile>
<AutoRun>yes</AutoRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>23000000</SoftResetVal>
<ResetAfterLoad>no</ResetAfterLoad>
<Dumpcore>no</Dumpcore>
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
<ConfigICE>
<IP>localhost</IP>
<PORT>1025</PORT>
<CPUNumber>0</CPUNumber>
<Clock>2000</Clock>
<Delay>10</Delay>
<WaitReset>50</WaitReset>
<DDC>yes</DDC>
<TRST>no</TRST>
<DebugPrint>no</DebugPrint>
<Connect>Normal</Connect>
<ResetType>Hard Reset</ResetType>
<SoftResetVal>21000000</SoftResetVal>
<RTOSType>Bare Metal</RTOSType>
<DownloadToFlash>yes</DownloadToFlash>
<ResetAfterConnect>yes</ResetAfterConnect>
<GDBName/>
<GDBServerType>Local</GDBServerType>
<OtherFlags>-arch riscv</OtherFlags>
</ConfigICE>
<ConfigSIM>
<SIMTarget/>
<OtherFlags/>
<NoGraphic>yes</NoGraphic>
<Log>no</Log>
<SimTrace>no</SimTrace>
</ConfigSIM>
<ConfigOpenOCD>
<OpenOCDExecutablePath>openocd-hifive</OpenOCDExecutablePath>
<OpenOCDTelnetPortEnable>no</OpenOCDTelnetPortEnable>
<OpenOCDTelnetPort>4444</OpenOCDTelnetPort>
<OpenOCDTclPortEnable>no</OpenOCDTclPortEnable>
<OpenOCDTclPort>6666</OpenOCDTclPort>
<OpenOCDConfigOptions>-f ../../../../tools/openocd/if_rv_dbg_plus.cfg -f ../../../../tools/openocd/tgt_702.cfg</OpenOCDConfigOptions>
</ConfigOpenOCD>
</Debug>
<Flash>
<InitFile/>
<Erase>Erase Sectors</Erase>
<Algorithms Path="">bl702_flasher.elf</Algorithms>
<Program>yes</Program>
<Verify>yes</Verify>
<ResetAndRun>no</ResetAndRun>
<ResetType>Hard Reset</ResetType>
<SoftResetVal/>
<External>no</External>
<Command/>
<Arguments/>
</Flash>
</BuildConfig>
</BuildConfigs>
</Project>

View file

@ -0,0 +1,188 @@
/**
* @file main.c
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#include "hal_usb.h"
#include "usbd_core.h"
#include "usbd_msc.h"
#include "hal_flash.h"
#include "ff.h"
#define MSC_IN_EP 0x85
#define MSC_OUT_EP 0x04
#define USBD_VID 0xFFFF
#define USBD_PID 0xFFFF
#define USBD_MAX_POWER 100
#define USBD_LANGID_STRING 1033
#define USB_CONFIG_SIZE (9 + MSC_DESCRIPTOR_LEN)
USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01),
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, 0x02),
///////////////////////////////////////
/// string0 descriptor
///////////////////////////////////////
USB_LANGID_INIT(USBD_LANGID_STRING),
///////////////////////////////////////
/// string1 descriptor
///////////////////////////////////////
0x12, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'B', 0x00, /* wcChar0 */
'o', 0x00, /* wcChar1 */
'u', 0x00, /* wcChar2 */
'f', 0x00, /* wcChar3 */
'f', 0x00, /* wcChar4 */
'a', 0x00, /* wcChar5 */
'l', 0x00, /* wcChar6 */
'o', 0x00, /* wcChar7 */
///////////////////////////////////////
/// string2 descriptor
///////////////////////////////////////
0x24, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'B', 0x00, /* wcChar0 */
'o', 0x00, /* wcChar1 */
'u', 0x00, /* wcChar2 */
'f', 0x00, /* wcChar3 */
'f', 0x00, /* wcChar4 */
'a', 0x00, /* wcChar5 */
'l', 0x00, /* wcChar6 */
'o', 0x00, /* wcChar7 */
' ', 0x00, /* wcChar8 */
'M', 0x00, /* wcChar9 */
'S', 0x00, /* wcChar10 */
'C', 0x00, /* wcChar11 */
' ', 0x00, /* wcChar12 */
'D', 0x00, /* wcChar13 */
'E', 0x00, /* wcChar14 */
'M', 0x00, /* wcChar15 */
'O', 0x00, /* wcChar16 */
///////////////////////////////////////
/// string3 descriptor
///////////////////////////////////////
0x16, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'2', 0x00, /* wcChar0 */
'0', 0x00, /* wcChar1 */
'2', 0x00, /* wcChar2 */
'1', 0x00, /* wcChar3 */
'0', 0x00, /* wcChar4 */
'3', 0x00, /* wcChar5 */
'1', 0x00, /* wcChar6 */
'0', 0x00, /* wcChar7 */
'0', 0x00, /* wcChar8 */
'0', 0x00, /* wcChar9 */
#ifdef CONFIG_USB_HS
///////////////////////////////////////
/// device qualifier descriptor
///////////////////////////////////////
0x0a,
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
0x00,
0x02,
0x00,
0x00,
0x00,
0x40,
0x01,
0x00,
#endif
0x00
};
/*The following parameters need to be modified simultaneously in bsp/bsp_common/fatfs/fatfs_usb.c!!*/
#define BLOCK_SIZE 4096
#define BLOCK_COUNT 256
#define FLASH_ADDR 0x00040000 /*addr start from 256k */
void usbd_msc_get_cap(uint8_t lun, uint32_t *block_num, uint16_t *block_size)
{
*block_num = BLOCK_COUNT;
*block_size = BLOCK_SIZE;
}
int usbd_msc_sector_read(uint32_t sector, uint8_t *buffer, uint32_t length)
{
flash_read(FLASH_ADDR + sector * BLOCK_SIZE, buffer, length);
return 0;
}
int usbd_msc_sector_write(uint32_t sector, uint8_t *buffer, uint32_t length)
{
flash_erase(FLASH_ADDR + sector * BLOCK_SIZE, BLOCK_SIZE);
flash_write(FLASH_ADDR + sector * BLOCK_SIZE, buffer, length);
return 0;
}
struct device *usb_fs;
FATFS fs;
FIL fnew;
UINT fnum;
FRESULT res_sd = 0;
uint8_t workbuf[4096];
uint8_t ReadBuffer[4096] = { 0 };
MKFS_PARM fs_para = {
.fmt = FM_FAT32, /* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */
.n_fat = 1, /* Number of FATs */
.align = 0, /* Data area alignment (sector) */
.n_root = 1, /* Number of root directory entries */
.au_size = 4096, /* Cluster size (byte) */
};
extern struct device *usb_dc_init(void);
extern void fatfs_usb_driver_register(void);
int main(void)
{
bflb_platform_init(0);
fatfs_usb_driver_register();
usbd_desc_register(msc_ram_descriptor);
usbd_msc_class_init(MSC_OUT_EP, MSC_IN_EP);
usb_fs = usb_dc_init();
if (usb_fs) {
device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP4_DATA_OUT_IT | USB_EP5_DATA_IN_IT));
}
while (!usb_device_is_configured()) {
}
while (1) {
cpu_global_irq_disable();
/*mount*/
f_mount(&fs, "2:", 1);
res_sd = f_open(&fnew, "2:1234.c", FA_OPEN_EXISTING | FA_READ);
if (res_sd == FR_OK) {
res_sd = f_read(&fnew, ReadBuffer, sizeof(ReadBuffer), &fnum);
bflb_platform_dump(ReadBuffer, fnum);
f_close(&fnew);
/*unmount*/
f_mount(NULL, "2:", 1);
} else {
MSG("open error\r\n");
}
cpu_global_irq_enable();
bflb_platform_delay_ms(2000);
}
}

View file

@ -0,0 +1,5 @@
```bash
$ make APP=usb_msc_flash BOARD=bl706_iot
```

View file

@ -0,0 +1,8 @@
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
set(TARGET_REQUIRED_LIBS usb_stack)
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb)
set(TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c)
set(mains main.c)
generate_bin()

View file

@ -0,0 +1,178 @@
/**
* @file main.c
* @brief
*
* Copyright (c) 2021 Bouffalolab team
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
#include "hal_usb.h"
#include "usbd_core.h"
#include "usbd_msc.h"
#include "hal_flash.h"
#include "hal_gpio.h"
#define MSC_IN_EP 0x85
#define MSC_OUT_EP 0x04
#define USBD_VID 0xFFFF
#define USBD_PID 0xFFFF
#define USBD_MAX_POWER 100
#define USBD_LANGID_STRING 1033
#define USB_CONFIG_SIZE (9 + MSC_DESCRIPTOR_LEN)
USB_DESC_SECTION const uint8_t msc_ram_descriptor[] = {
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01),
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
MSC_DESCRIPTOR_INIT(0x00, MSC_OUT_EP, MSC_IN_EP, 0x02),
///////////////////////////////////////
/// string0 descriptor
///////////////////////////////////////
USB_LANGID_INIT(USBD_LANGID_STRING),
///////////////////////////////////////
/// string1 descriptor
///////////////////////////////////////
0x12, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'B', 0x00, /* wcChar0 */
'o', 0x00, /* wcChar1 */
'u', 0x00, /* wcChar2 */
'f', 0x00, /* wcChar3 */
'f', 0x00, /* wcChar4 */
'a', 0x00, /* wcChar5 */
'l', 0x00, /* wcChar6 */
'o', 0x00, /* wcChar7 */
///////////////////////////////////////
/// string2 descriptor
///////////////////////////////////////
0x24, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'B', 0x00, /* wcChar0 */
'o', 0x00, /* wcChar1 */
'u', 0x00, /* wcChar2 */
'f', 0x00, /* wcChar3 */
'f', 0x00, /* wcChar4 */
'a', 0x00, /* wcChar5 */
'l', 0x00, /* wcChar6 */
'o', 0x00, /* wcChar7 */
' ', 0x00, /* wcChar8 */
'M', 0x00, /* wcChar9 */
'S', 0x00, /* wcChar10 */
'C', 0x00, /* wcChar11 */
' ', 0x00, /* wcChar12 */
'D', 0x00, /* wcChar13 */
'E', 0x00, /* wcChar14 */
'M', 0x00, /* wcChar15 */
'O', 0x00, /* wcChar16 */
///////////////////////////////////////
/// string3 descriptor
///////////////////////////////////////
0x16, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'2', 0x00, /* wcChar0 */
'0', 0x00, /* wcChar1 */
'2', 0x00, /* wcChar2 */
'1', 0x00, /* wcChar3 */
'0', 0x00, /* wcChar4 */
'3', 0x00, /* wcChar5 */
'1', 0x00, /* wcChar6 */
'0', 0x00, /* wcChar7 */
'0', 0x00, /* wcChar8 */
'0', 0x00, /* wcChar9 */
#ifdef CONFIG_USB_HS
///////////////////////////////////////
/// device qualifier descriptor
///////////////////////////////////////
0x0a,
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
0x00,
0x02,
0x00,
0x00,
0x00,
0x40,
0x01,
0x00,
#endif
0x00
};
/*The following parameters need to be modified simultaneously in bsp/bsp_common/fatfs/fatfs_usb.c!!*/
#define BLOCK_SIZE 4096
#define BLOCK_COUNT 64
#define FLASH_ADDR 0x0000c000 /*addr start from 48k */
void usbd_msc_get_cap(uint8_t lun, uint32_t *block_num, uint16_t *block_size)
{
*block_num = BLOCK_COUNT;
*block_size = BLOCK_SIZE;
}
int usbd_msc_sector_read(uint32_t sector, uint8_t *buffer, uint32_t length)
{
flash_read(FLASH_ADDR + sector * BLOCK_SIZE, buffer, length);
return 0;
}
int usbd_msc_sector_write(uint32_t sector, uint8_t *buffer, uint32_t length)
{
flash_erase(FLASH_ADDR + sector * BLOCK_SIZE, BLOCK_SIZE);
flash_write(FLASH_ADDR + sector * BLOCK_SIZE, buffer, length);
return 0;
}
struct device *usb_fs;
extern struct device *usb_dc_init(void);
int main(void)
{
bflb_platform_init(0);
gpio_set_mode(GPIO_PIN_15, GPIO_INPUT_PD_MODE);
if (gpio_read(GPIO_PIN_15)) {
MSG("*************Welcome to usb msc boot,update your app bin*************\r\n");
usbd_desc_register(msc_ram_descriptor);
usbd_msc_class_init(MSC_OUT_EP, MSC_IN_EP);
usb_fs = usb_dc_init();
if (usb_fs) {
device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP4_DATA_OUT_IT | USB_EP5_DATA_IN_IT));
}
while (!usb_device_is_configured()) {
}
} else {
uint8_t bin_header;
flash_read(FLASH_ADDR + 10 * BLOCK_SIZE, &bin_header, 1);
if ((bin_header == 0x00) && (bin_header == 0xff)) {
MSG("*************Illegal bin!! Please update your bin*************\r\n");
while (1) {
}
}
MSG("*************Let's go to application*************\r\n");
bflb_platform_delay_ms(20);
bflb_platform_deinit();
hal_jump2app(FLASH_ADDR + 10 * BLOCK_SIZE);
}
while (1) {
bflb_platform_delay_ms(1000);
}
}

View file

@ -0,0 +1,7 @@
**先将本 demo 的 bin 烧录到芯片后,将 gpio15 引脚拉高复位进入 u 盘升级,如果不想升级,将 gpio15 拉低即可**
```bash
$ make APP=usb_msc_flash_boot BOARD=bl706_iot
```