en:arm_programming
Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | en:arm_programming [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== ARM STM32 processors programming ====== | ||
+ | |||
+ | The best working environment for ARM processors is the Linux OS. That is why the following manual describes the installation process and how to handle the tools for work with ARM in this particular system. [[http:// | ||
+ | |||
+ | All the software that is mentioned in this guide can be obtained for free. | ||
+ | |||
+ | ===== Introduction for beginners ===== | ||
+ | |||
+ | A required HW includes: | ||
+ | |||
+ | * ARM processor of your choice with necessary peripherals ([[en: | ||
+ | * Program __loading__ | ||
+ | * Through a serial link ([[en: | ||
+ | * J-TAG ([[en: | ||
+ | |||
+ | A required SW includes: | ||
+ | * SW for writing the code | ||
+ | * Compiler | ||
+ | * Loading of the compiled program | ||
+ | |||
+ | |||
+ | ===== Compiler ===== | ||
+ | |||
+ | You can use a freely available GNU C compiler, obtainable from git repository [[https:// | ||
+ | |||
+ | To help you with the Ubuntu installation it is possible to used a ready-made [[https:// | ||
+ | |||
+ | == Quick installation using a software repository == | ||
+ | |||
+ | sudo add-apt-repository ppa: | ||
+ | sudo apt-get update | ||
+ | sudo apt-get install gcc-arm-none-eabi | ||
+ | | ||
+ | == Compilation procedure == | ||
+ | |||
+ | Open a terminal and change the directory to the one containing the compilation files. Start the compilation process using the MAKE command. | ||
+ | |||
+ | | ||
+ | ===== GUI ===== | ||
+ | |||
+ | |||
+ | ==== Sublime text ==== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | |||
+ | ==== Code:: | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | sudo apt-get install codeblocks | ||
+ | | ||
+ | ===== Libraries ===== | ||
+ | |||
+ | ==== STM32F10X standard peripheral library ==== | ||
+ | |||
+ | The complete proprietary library from STMicroelectronics, | ||
+ | |||
+ | It is available for download at [[http:// | ||
+ | |||
+ | |||
+ | ==== libopencm3 ==== | ||
+ | |||
+ | A new open-source library with better interface and smaller size, that in unfortunately yet incomplete (though under an ongoing development). | ||
+ | |||
+ | |||
+ | [[http:// | ||
+ | |||
+ | ===== Loading ===== | ||
+ | |||
+ | ==== Bootloader ==== | ||
+ | |||
+ | The use of bootloader is useful in cases when we do not intend to use any additional programming HW and we do not need advanced developmental functions like debugger. | ||
+ | |||
+ | === STM32F10xRxT01A module === | ||
+ | |||
+ | To activate the bootloader, hold the BOOT key, then press the RESET key and immediately release the BOOT key. It is possible to communicate with the bootloader through USB or UART (using e.g. [[http:// | ||
+ | |||
+ | |||
+ | == Connecting the module == | ||
+ | |||
+ | In order to be able to use the bootloader, it in necessary to connect it to the serial link. In the case of using [[en: | ||
+ | |||
+ | |||
+ | ^ USB232R01B ^ STM32F10xRxT01A | ||
+ | | TXD | PA10 | | ||
+ | | RXD | PA9 | | ||
+ | |||
+ | Professionals can connect other DTR and RTS signals as well, to get rid of an annoying pressing of the keys during every upload :) | ||
+ | (This function requires a modified stm32flash). | ||
+ | |||
+ | |||
+ | == stm32flash compilation == | ||
+ | |||
+ | svn checkout http:// | ||
+ | cd stm32flash-read-only | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | |||
+ | An example of use: | ||
+ | |||
+ | sudo stm32flash / | ||
+ | | ||
+ | stm32flash - http:// | ||
+ | | ||
+ | Serial Config: 57600 8E1 | ||
+ | Version | ||
+ | Option 1 : 0x00 | ||
+ | Option 2 : 0x00 | ||
+ | Device ID : 0x0418 (Connectivity line) | ||
+ | RAM : 64KiB (4096b reserved by bootloader) | ||
+ | Flash : 256KiB (sector size: 2x2048) | ||
+ | Option RAM : 15b | ||
+ | System RAM : 18KiB | ||
+ | | ||
+ | Resetting device... done. | ||
+ | |||
+ | An example of program loading: | ||
+ | |||
+ | $ ./ | ||
+ | stm32flash - http:// | ||
+ | | ||
+ | Using Parser : Intel HEX | ||
+ | Serial Config: 57600 8E1 | ||
+ | Version | ||
+ | Option 1 : 0x00 | ||
+ | Option 2 : 0x00 | ||
+ | Device ID : 0x0414 (High-density) | ||
+ | RAM : 64KiB (512b reserved by bootloader) | ||
+ | Flash : 512KiB (sector size: 2x2048) | ||
+ | Option RAM : 15b | ||
+ | System RAM : 2KiB | ||
+ | | ||
+ | Wrote and verified address 0x08000c48 (100.00%) Done. | ||
+ | Starting execution at address 0x08000000... done. | ||
+ | | ||
+ | === dfu-util === | ||
+ | |||
+ | The binaries for this utility can be found here: [[http:// | ||
+ | |||
+ | To activate the bootloader through USB, you have to connect + 3,3 V to the PA9 pin. In order to run the bootloader follow the sequence: press RESET, press BOOT, release RESET, release BOOT. | ||
+ | |||
+ | A __batch__ to call the dfu-util on Windows platform and the compiled version of dfu-until without the need to download other libraries can be found here: [[http:// | ||
+ | |||
+ | You can test the firmware loading, using this sample binary, that creates the USB HID mouse out of the STM32F107 processor. [[http:// | ||
+ | |||
+ | | ||
+ | ==== J-TAG ==== | ||
+ | |||
+ | An external programmer is required to program through JTAG. In the case of [[cs: | ||
+ | |||
+ | For programing is suitable eg. [[http:// | ||
+ | |||
+ | |||
+ | === Ubuntu === | ||
+ | |||
+ | Though there already exist natively supported packages for OpenOCD in Ubuntu, their versions are usually | ||
+ | quite old compared to the latest development. It is therefore recommended to compile the current version... | ||
+ | |||
+ | sudo apt-get install libtool git gcc automake libftdi-dev texinfo | ||
+ | git clone git:// | ||
+ | cd openocd-code/ | ||
+ | ./bootstrap | ||
+ | ./configure --enable-maintainer-mode --disable-werror --enable-ft2232_libftdi | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | To uninstal the OpenOCD, use the following command | ||
+ | |||
+ | sudo make uninstall | ||
+ | |||
+ | If you have a [[cs: | ||
+ | |||
+ | sudo openocd -f " | ||
+ | | ||
+ | Open On-Chip Debugger 0.7.0-rc1-dev-00011-gd9ba56c (2013-04-28-11: | ||
+ | Licensed under GNU GPL v2 | ||
+ | For bug reports, read | ||
+ | http:// | ||
+ | Info : only one transport option; autoselect ' | ||
+ | adapter speed: 1000 kHz | ||
+ | adapter_nsrst_delay: | ||
+ | jtag_ntrst_delay: | ||
+ | cortex_m3 reset_config sysresetreq | ||
+ | Info : max TCK change to: 30000 kHz | ||
+ | Info : clock speed 1000 kHz | ||
+ | Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3) | ||
+ | Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1) | ||
+ | Info : stm32f1x.cpu: | ||
+ | |||
+ | |||
+ | Tho OpenOCD has created a server, that you can connect with through telnet | ||
+ | |||
+ | telnet localhost 4444 | ||
+ | | ||
+ | Trying 127.0.0.1... | ||
+ | Connected to localhost. | ||
+ | Escape character is ' | ||
+ | Open On-Chip Debugger | ||
+ | > | ||
+ | |||
+ | |||
+ | === Mac OS X === | ||
+ | |||
+ | |||
+ | ./configure --enable-ft2232_ftd2xx openocd -f busblaster.cfg -f / | ||
+ | \\ | ||
+ | busblaster.cfg: | ||
+ | interface ft2232 | ||
+ | ft2232_device_desc "Dual RS232-HS" | ||
+ | ft2232_layout jtagkey | ||
+ | ft2232_vid_pid 0x0403 0x6010 | ||
+ | |||
+ | basic info: http:// | ||
+ | |||
+ | ===== RTOS ===== | ||
+ | |||
+ | ==== Chibios ==== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | Chibios is a basic realtime OS with HAL component that simplifies the work with a microprocessor. To facilitate the work, a Chibios configuration directly for module with ARM has been created, and it is available at [[https:// | ||
+ | |||
+ | In order to obtain more documentation use [[http:// | ||
+ | |||
+ | === LED blink demo === | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | | ||
+ | int main(void) { | ||
+ | | ||
+ | halInit(); | ||
+ | chSysInit(); | ||
+ | | ||
+ | while (TRUE) { | ||
+ | palTogglePad(GPIOB, | ||
+ | chThdSleepMilliseconds(250); | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
en/arm_programming.txt · Last modified: 2013/11/08 13:05 (external edit)