查看EFM32的源代码
←
EFM32
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== Toolchain == === Overview === EFM32 的刷写和调试协议规范:[https://www.silabs.com/documents/public/application-notes/an0062.pdf AN0062 Programming Internal Flash Over SWDI] 刷写硬件官方推荐 SEGGER 公司的 J-Link,EFM32 开发板都集成了。。。配套使用官方工具 Commander (JLinkARM.dll) 也可以使用 STLINK V2,配套使用 OpenOCD。。。 <br> === OpenOCD === [http://www.openocd.org/doc/html/Flash-Commands.html OpenOCD Doc] [https://www.silabs.com/community/software/simplicity-studio/forum.topic.html/efm32_developmentde-LqeK UserData support patch] [https://www.allaboutcircuits.com/technical-articles/getting-started-with-openocd-using-ft2232h-adapter-for-swd-debugging/ FT2232H OpenOCD] [https://mindchasers.com/dev/openocd-darsena-windows Build OpenOCD in Windows] https://elinux.org/Compiling_OpenOCD_Win7 [https://www.allaboutcircuits.com/technical-articles/getting-started-with-openocd-using-ft2232h-adapter-for-swd-debugging/ OpenOCD with FT2232H] 1. Download and install [https://cygwin.com/setup-x86.exe setup-x86.exe (32-bit system)] 2. 选择 Install from Internet, 在 "User URL" 处输入以下地址: https://mirrors.tuna.tsinghua.edu.cn/cygwin/ 点击 Add 按钮, 然后选中 https://mirrors.tuna.tsinghua.edu.cn, 点击”下一步”进行安装。 3. 选择如下软件包: <pre> autobuild autoconf autoconf-archive automake libtool make pkg-config git patchutils ################ mingw64-i686-binutils mingw64-i686-gcc-core mingw64-i686-pthreads mingw64-i686-runtime mingw64-i686-libusb 1.0 ################ </pre> 运行环境如果是 cygwin(不推荐) 则把如上相关包换成: <pre> gcc-core libusb1.0 libusb1.0-devel usbutils </pre> 4. git clone <source lang=bash> $ git clone git://git.code.sf.net/p/openocd/code openocd $ cd openocd $ mkdir build $ cd build $ ../configure --enable-ftdi --enable-stlink --disable-doxygen-html --disable-werror --disable-libtool-lock --build=i686-pc-cygwin --host=i686-w64-mingw32 $ make $ make install </source> 编译完后,找到 libgcc_s_sjlj-1.dll libusb-1.0.dll openocd.exe 置于: dist/bin/ 下,usr/local/share/openocd 放在 dist/share 下,打包 dist/ 即可 release 到其他机器运行 You can flash the bin file into the EFM32 via OpenOCD with STLINK V2: '''Pin:''' * PIN19 --- PF0 --- DBG_SWCLK -----> STLINK_V2-SWCLK * PIN20 --- PF1 --- DBG_SWDIO -----> STLINK_V2-SWDIO * PIN-7 --- RSTn --- RESET ---> STLINK_V2-Reset Windows: * http://gnutoolchains.com/arm-eabi/openocd/ Flashing the toboot with ST-Link: <source lang=bash> $ ../../toolchain/openocd/bin/openocd -f interface/stlink.cfg -c "set CPUTAPID 0x0bc11477; source [find target/efm32.cfg]; \ init; targets; reset halt; flash probe 0; flash write image erase eerpom.bin; verify reset; shutdown" Open On-Chip Debugger 0.10.0 (2019-10-24) [https://github.com/sysprogs/openocd] Licensed under GNU GPL v2 libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD Info : clock speed 1000 kHz Info : STLINK V2J27S6 (API v2) VID:PID 0483:3748 Info : Target voltage: 3.233400 Info : efm32.cpu: hardware has 4 breakpoints, 2 watchpoints Info : Listening on port 3333 for gdb connections target halted due to debug-request, current mode: Thread xPSR: 0x81000000 pc: 0x000005e8 msp: 0x20001000 Info : detected part: EFM32ZG Zero Gecko, rev 143 Info : flash size = 32kbytes Info : flash page size = 1024bytes efm32 flash flash bank bank_id driver_name base_address size_bytes chip_width_bytes bus_width_bytes target [driver_options ...] flash banks flash erase_address ['pad'] ['unlock'] address length flash erase_check bank_id flash erase_sector bank_id first_sector_num (last_sector_num|'last') flash fillb address value n flash fillh address value n flash fillw address value n flash info bank_id ['sectors'] flash init flash list flash padded_value bank_id value flash probe bank_id flash protect bank_id first_block [last_block|'last'] ('on'|'off') flash read_bank bank_id filename [offset [length]] flash verify_bank bank_id filename [offset] flash write_bank bank_id filename [offset] flash write_image [erase] [unlock] filename [offset [file_type]] gdb_flash_program ('enable'|'disable') </source> <br> '''J-Link:''' '''J-Link:''' [[文件:JLink Interface Pinout SWD.jpg]] 使用 5 根线: VTref, GND, SWIO, SWCLK, RESET <source lang=bash> $ ../../toolchain/openocd-nt/bin/openocd -f interface/jlink.cfg -c "transport select swd; set CPUTAPID 0x0bc11477; source [find target/efm32.cfg]; init; targets; reset halt; program build/main.bin verify reset; shutdown" Open On-Chip Debugger 0.10.0+dev-00957-g9de7d9c8 (2019-11-18-15:06) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : J-Link V9 compiled Dec 13 2019 11:14:50 Info : Hardware version: 9.30 Info : VTarget = 3.295 V Info : clock speed 1000 kHz Info : SWD DPIDR 0x0bc11477 Info : efm32.cpu: hardware has 4 breakpoints, 2 watchpoints Info : efm32.cpu: external reset detected Info : Listening on port 3333 for gdb connections target halted due to debug-request, current mode: Thread xPSR: 0x21000000 pc: 0x00000674 msp: 0x20001000 target halted due to debug-request, current mode: Thread xPSR: 0x21000000 pc: 0x00000674 msp: 0x20001000 ** Programming Started ** Info : detected part: EFM32ZG Zero Gecko, rev 143 Info : flash size = 32kbytes Info : flash page size = 1024bytes ** Programming Finished ** ** Verify Started ** ** Verified OK ** ** Resetting Target ** shutdown command invoked comca@AI-Workstation MINGW32 ~/work/nodetao/toolchain (master) $ ./openocd-nt/bin/openocd -f interface/jlink.cfg -c "transport select swd; set CPUTAPID 0x0bc11477; source [find target/efm32.cfg]; init; targets; reset halt; program ../sketch/aeco-hrx/fw/T2abc-v0613-nodbg.bin verify reset; shutdown" Open On-Chip Debugger 0.10.0+dev-00957-g9de7d9c8 (2019-11-18-15:06) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : J-Link V9 compiled Dec 13 2019 11:14:50 Info : Hardware version: 9.30 Info : VTarget = 3.291 V Info : clock speed 1000 kHz Info : SWD DPIDR 0x0bc11477 Info : efm32.cpu: hardware has 4 breakpoints, 2 watchpoints Info : efm32.cpu: external reset detected Info : Listening on port 3333 for gdb connections target halted due to debug-request, current mode: Thread xPSR: 0x21000000 pc: 0x00000e84 msp: 0x20001000 target halted due to debug-request, current mode: Thread xPSR: 0x21000000 pc: 0x00000e84 msp: 0x20001000 ** Programming Started ** Info : detected part: EFM32ZG Zero Gecko, rev 143 Info : flash size = 32kbytes Info : flash page size = 1024bytes ** Programming Finished ** ** Verify Started ** ** Verified OK ** ** Resetting Target ** shutdown command invoked </source> <br> === Commander === '''硬件使用 J-Link:''' [[文件:JLink Interface Pinout SWD.jpg]] 使用 5 根线: VTref, GND, SWIO, SWCLK, RESET Simplicity Commander is the Silabs official tool. It is invoked using a simple Command Line Interface (CLI). * Flash their own applications. * Configure their own applications. * Create binaries for production. Simplicity Commander is designed to support the Silicon Labs Wireless STK and STK platforms By default in Studio v4, Simplicity Commander can be found at the following path: C:\SiliconLabs\SimplicityStudio\v4\developer\adapter_packs\commander\commander.exe '''Doc:''' [http://www.silabs.com/documents/public/user-guides/ug162-simplicity-commander-reference-guide.pdf Simplicity Commander Reference Guide] '''[https://www.silabs.com/products/mcu/programming-options Download:]''' * https://www.silabs.com/documents/public/software/SimplicityCommander-Windows.zip * https://www.silabs.com/documents/public/software/SimplicityCommander-Linux.zip * https://www.silabs.com/documents/public/software/SimplicityCommander-Mac.zip '''Basic:''' <source lang=bash> $ commander flash --help $ commander adapter probe --serialno <J-Link serial number> [--kit] [--boards] [--firmware] $ commander adapter probe --serialno 440050184 $ commander adapter reset $ commander device info --tif SWD–-speed 1000 # 1000 ~ 8000 kHz # If the --tif and --speed options are not used, the default configuration is SWD and 4000 kHz Setting debug interface speed to 1000 kHz Setting debug interface to SWD Part Number : EFR32BG1P332F256GJ43 Die Revision : A2 Production Ver : 138 Flash Size : 256 kB SRAM Size : 32 kB Unique ID : 000b57fffe0934e3 DONE </source> '''Program user data page:''' <source lang=bash> $ commander.exe readmem --range 0x0FE081F0:0x0FE081F8 -d EFM32ZG110F32 # show the chip uuid @devinfo region $ commander readmem --region @userdata --outfile user.hex -d EFM32ZG110F32 # or: .bin, .s37 Reading 2048 bytes from 0x0fe00000... Writing to userpage.hex... DONE $ commander flash --address 0x0fe00000 12008130001.bin -d EFM32ZG110F32 # --region: EFM32, EZR32, EFR32: @mainflash, @userdata, @lockbits, @devinfo # EM3xx: @mfb, @cib, @fib $ commander readmem --range 0x0FE00000:+8 -d EFM32ZG110F32 # show the first 8 bytes @userdata region $ commander device pageerase --region @userdata # erase the userdata area Erasing range 0x0fe00000 - 0x0fe00400 DONE $ commander device pageerase –-range 0x200:0x6000 Erasing range 0x00000000 - 0x00006000 DONE </source> '''Flash serveral files:''' <source lang=bash> $ commander flash blink.s37 userpage.hex Adding file blink.s37... Adding file userpage.hex... Flashing 2812 bytes, starting at address 0x00000000 Resetting... Uploading flash loader... Waiting for flashloader to become ready... Erasing flash... Flashing... Verifying written data... Finished! Flashing 2048 bytes, starting at address 0x0fe00000 Resetting... Uploading flash loader... Waiting for flashloader to become ready... Erasing flash... Flashing... Verifying written data... Resetting... Finished! DONE </source> '''Patch Flash:''' <source lang=bash> $ commander flash -–patch <address>:<data>[:length] $ commander flash --patch 0x120:0xAB --patch 0x3200:0xA5A5:2 Patching 0x00000120 = 0xAB... Patching 0x00003200 = 0xA5A5... Flashing 2048 bytes, starting at address 0x00000000 Resetting... Uploading flash loader... Waiting for flashloader to become ready... Erasing flash... Flashing... Verifying written data... Finished! Flashing 2048 bytes, starting at address 0x00003000 Resetting... Uploading flash loader... Waiting for flashloader to become ready... Erasing flash... Flashing... Verifying written data... Resetting... Finished! DONE </source> ''' Device Lock and Protection:''' <source lang=bash> $ commander device lock –-debug enable Locking debug access... DONE $ commander device lock –-debug disable ERROR: Could not get MCU information Removing all locks/protection... Unlocking debug access (triggers a mass erase)... DONE $ commander device protect --write --range <startaddress>:<endaddress> $ commander device protect --write --range 0x0:0x4000 # Protects all flash pages in the first 16 kB $ commander device protect --write --region @mainflash Write-protecting all pages in main flash. DONE $ commander device protect --write --disable Disabling all write protection for all pages DONE </source> <source lang=bash> $ commander device masserase Erasing chip... DONE $ commander device reset Resetting chip... DONE $ commander device recover Recovering "bricked" device... DONE $ commander aem measure [–-windowlength <time in ms>] $ commander aem measure –-windowlength 200 Averaged over 200 ms: Current [mA]: 5.359 Power [mW] : 17.763 Voltage [V] : 3.314 DONE </source> <br><br>
返回到
EFM32
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面