Updated Blinky on Olimex tutorial. Closes pull request #53
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/477d85dc Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/477d85dc Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/477d85dc Branch: refs/heads/asf-site Commit: 477d85dcd7af74a00a83cb0f980ae9444882e45c Parents: 2393faf Author: aditihilbert <ad...@runtime.io> Authored: Wed Mar 16 18:25:42 2016 -0700 Committer: aditihilbert <ad...@runtime.io> Committed: Wed Mar 16 18:25:42 2016 -0700 ---------------------------------------------------------------------- mkdocs/search_index.json | 35 ++- os/tutorials/olimex/index.html | 424 ++++++++++++++++------------------ os/tutorials/pics/bottomview.png | Bin 1995826 -> 701983 bytes os/tutorials/pics/topview.png | Bin 1945584 -> 723333 bytes sitemap.xml | 20 +- 5 files changed, 232 insertions(+), 247 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/477d85dc/mkdocs/search_index.json ---------------------------------------------------------------------- diff --git a/mkdocs/search_index.json b/mkdocs/search_index.json index 034f2e2..4843986 100644 --- a/mkdocs/search_index.json +++ b/mkdocs/search_index.json @@ -247,7 +247,7 @@ }, { "location": "/os/tutorials/olimex/", - "text": "Blinky, Your Hello World!\n\n\nObjective\n\n\nLearn how to use packages from a default application repository of Mynewt to build your first \nHello World\n application (Blinky) on a target board. Once built using \nnewt\n tool, this application will blink the LED lights on the target board. Fun stuff!\n\n\nThis tutorial will guide to achieve the following, assuming you have already set up the environment on your computer to use Mynewt OS and newt tool:\n\n\nDownload packages and use tools to create a runtime image for a board to make its LED blink. You have two choices here:\n * \nDownload an image to SRAM\n, or \n * \nDownload it to flash\n.\n\n\n Time Requirement\n: Allow yourself a couple of hours for this project if you are relatively new to embedded systems and playing with development boards. Those jumpers can be pesky!\n\n\nWhat you need\n\n\n\n\nSTM32-E407 development board from Olimex. You can order it from \nhttp://www.mouser.com\n, \nhttp://www. digikey.com\n, and other places.\n\n\nARM-USB-TINY-H connector with JTAG interface for debugging ARM microcontrollers (comes with the ribbon cable to hook up to the board)\n\n\nUSB A-B type cable to connect the debugger to your personal computer\n\n\nPersonal Computer with Mac OS (Mac: OS X Yosemite Version 10.10.5) or Linux box (Ubuntu 14.10: Utopic Unicorn)\n\n\nAn account on Github repository and \ngit\n installed on your computer.\n\n\nIt assumed you already installed native tools described \nhere\n\n\n\n\nAlso, we assume that you're familiar with UNIX shells.\n\n\nLet's gets started!\n\n\nUse SRAM to make LED blink\n\n\nIf you wish to build the image to run from the onboard SRAM on Olimex board, follow the steps below:\n\n\nPreparing the Software\n\n\n\n\n\n\nMake sure the PATH environment variable includes the $HOME/dev/go/bin directory. \n\n\n\n\n\n\nIf you have cloned the larva repository for the simulator test in the previous section, you can skip this step. Otherwise, you have to create a repository for the project. Go to ~/dev and clone the larva repository from the apache git repository into a local directory named \nlarva\n.\n\n\n\n\n\n\n $ cd ~/dev \n $ git clone https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva.git larva\n $ ls\n\n go larva\n $ ls larva\n DISCLAIMER NOTICE app.yml compiler hw net project sys\n LICENSE README.md autotargets fs libs pkg-list.yml scripts\n\n\n\n\n\n\n\n\n\nChange directory to ~dev/larva directory and build the \nblinky\n project inside larva, using the \nnewt\n tool. Starting with the target name, assign specific aspects of the project, as shown below, to pull the appropriate packages and build the right bundle or list for the board. For example, we set the architecture (arch), compiler, board support package (bsp), project, and compiler mode.\n\n\n(Remember to prefix each command with \"newtvm\" if you are executi ng the newt command in a Linux virtual machine on your Windows box!)\n\n\n\n\n\n\n $ newt target create blinky\n Creating target blinky\n Target blinky sucessfully created!\n $ newt target set blinky arch=cortex_m4\n Target blinky successfully set arch to arm\n $ newt target set blinky compiler=arm-none-eabi-m4\n Target blinky successfully set compiler to arm-none-eabi-m4\n $ newt target set blinky project=blinky\n Target blinky successfully set project to blinky\n $ newt target set blinky compiler_def=debug\n Target blinky successfully set compiler_def to debug\n $ newt target set blinky bsp=hw/bsp/olimex_stm32-e407_devboard\n Target blinky successfully set bsp to hw/bsp/olimex_stm32-e407_devboard\n $ newt target show blinky\n blinky\n arch=cortex_m4\n bsp=hw/bsp/olimex_stm32-e407_devboard\n compiler=arm-none-eabi-m4\n compiler_def=deb ug\n name=blinky\n project=blinky\n\n\n\n\n\n\n\nNext, let's build the image with the above values assigned. By default, the linker script within the \nhw/bsp/olimex_stm32-e407_devboard\n package builds an image for flash memory, which we don't want; instead, we want an image for the SRAM, so you need to switch that script with \nrun_from_sram.ld\n. \n\n\n\n\n\n(We are working to simplify this scheme whereby an executable for a project will correctly elect the linker scripts and generate the relevant image. For example, the scheme will key on project identity such as bootloader, RAM, Flash (default) and build accordingly. \n.)\n\n\nAfer you build the target, you can find the executable *blinky.elf* in the project directory *~/dev/larva/project/blinky/bin/blinky.*\n\n\n\n\n\n $ cd ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard\n $ diff olimex_stm32-e407_devboard.ld run_from_sram.ld\n (some diff will be displayed)\n $ cp run_from_sram.l d olimex_stm32-e407_devboard.ld\n $ cd ~/dev/larva/project/blinky/\n $ newt target build blinky\n Building target blinky (project = blinky)\n Compiling case.c\n Compiling suite.c\n ...\n Successfully run!\n $ ls bin/blinky\n blinky.elf blinky.elf.bin blinky.elf.cmd blinky.elf.lst blinky.elf.map\n\n\n\n\n\n\n\nCheck if you have all the scripts needed to launch OpenOCD and interact with the project's specific hardware. Depending on your system (Ubuntu or Windows) you may already have the scripts in your \n/usr/share/openocd/scripts/\n directory, as they may have been part of the openocd download. If they exist, you are all set and can proceed to prepare the hardware. Otherwise check the \n~/dev/larva/hw/bsp/olimex_stm32-e407_devboard\n directory for a file named \nf407.cfg\n. Used by OpenOCD, this config enables us to interact with this specific hardware. \n\n\n\n\nYou are all set if you see the file.\n\n\n $ ls ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard\n bin include olimex_stm32-e407_devboard_download.sh run_from_loader.ld\n boot-olimex_stm32-e407_devboard.ld olimex_stm32-e407_devboard.ld pkg.yml run_from_sram.ld\n f407.cfg olimex_stm32-e407_devboard_debug.sh run_from_flash.ld src\n\n\n\n\n\nPrepare the hardware to boot from embedded SRAM\n\n\n\n\n\n\nLocate the boot jumpers on the board.\n\n\n\n\n\n\n\n\n\nB1_1/B1_0 and B0_1/B0_0 are PTH jumpers. Note that because the markings on the board may not always be accurate, when in doubt, you should always refer to the manual for the correct positioning. Since the jumpers are a pair, they should move together, and as such, the pair is responsible for the boot mode when bootloader is present. \nTo locate the bootloader, the board searches in three places: User Flash Memory, System Memory or the Embedded SRAM. For this Blinky project, we will configure it to boot from SRAM by jumpering \nB 0_1\n and \nB1_1\n.\n\n\n\n\n\n\nConnect USB-OTG#2 in the picture above to a USB port on your computer (or a powered USB hub to make sure there is enough power available to the board). \n\n\n\n\n\n\nThe red PWR LED should be lit. \n\n\n\n\n\n\nConnect the JTAG connector to the SWD/JTAG interface on the board. The other end of the cable should be connected to the USB port or hub of your computer.\n\n\n\n\n\n\nLet's Go!\n\n\n\n\nEnsure that you are in the blinky project directory with the \nblinky.elf\n executable. Run the debug command in the \nnewt\n tool. You'll see some status messages as shown below. In case you need to halt the debugging session, you can issue an \n-c \"reset halt\"\n command.\n\n\n\n\n $ cd ~/dev/larva/project/blinky/bin/blinky\n $ newt target debug blinky\n Debugging with /Users/aditihilbert/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh blinky\n Debugging /Users/aditihilbert/dev/larva/project/blinky /bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 or later \nhttp://gnu.org/licenses/gpl.html\n\n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x20000250 msp: 0x10010000\n Info : accepting \ngdb\n connection from 3333\n Info : device id = 0x10036413\n Info : flash size = 1024kbytes\n Reset_Handler () at startup_STM32F40x.s:199\n 199 ldr r1, =__etext\n\n\n\n\n\nCheck the value of the msp (main service pointer) register. If it is not 0x10010000 as indicated above, you will have to manually set it after you open the gdp tool and load the image on it. For example, \n\n\n (gdb) set $\nmsp\n=0x10010000\n\n\n\n\n\nNow load the image and type \"c\" or \"continue\" from the G NU debugger. \n\n\n (gdb) load ~/dev/larva/project/blinky/bin/blinky/blinky.elf \n Loading section .text, size 0x4294 lma 0x20000000\n Loading section .ARM.extab, size 0x24 lma 0x20004294\n Loading section .ARM.exidx, size 0xd8 lma 0x200042b8\n Loading section .data, size 0x874 lma 0x20004390\n Start address 0x20000250, load size 19460\n Transfer rate: 81 KB/sec, 2432 bytes/write.\n (gdb) c\n Continuing.\n\n\n\n\n\n\n\nVoil\u00e0! The board's LED should be blinking at 1 Hz. Success!\n\n\n\n\nUse flash to make LED blink\n\n\nIf you wish to build the image to run from the onboard flash memory on Olimex board, follow the steps below:\n\n\n\n\nConfigure the board to boot from flash by moving the two jumpers together to \nB0_0\n and \nB1_0\n. Refer to the pictures of the board under the section titled \n\"Prepare the hardware to boot from embedded SRAM\"\n.\n\n\n\n\nYou will have to reset the board once the image is u ploaded to it.\n\n\n\n\nIf you skipped the first option for the project \n(downloading an image to SRAM)\n, then skip this step. Otherwise, continue with this step. \n\n\n\n\nBy default, the linker script (\nolimex_stm32-e407_devboard.ld\n) is configured to run from bootloader and flash. However, if you first ran the image from SRAM you had changed \nolimex_stm32-e407_devboard.ld\n to match \nrun_from_sram.ld\n. You will, therefore, return to defaults with \nolimex_stm32-e407_devboard.ld\n linker script matching the contents of 'run_from_loader.ld'. Return to the project directory.\n\n\n $ cd ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard\n $ diff olimex_stm32-e407_devboard.ld run_from_sram.ld\n $ diff olimex_stm32-e407_devboard.ld run_from_loader.ld\n (some diff will be displayed)\n $ cp run_from_loader.ld olimex_stm32-e407_devboard.ld\n $ cd ~/dev/larva/project/blinky/bin/blinky\n\n\n\n\n\n\n\nIn order to run the image from flash, you need to build the bootloader as well. The bootloader does the initial set up of the Olimex board and then transfers control to the image stored at a location in flash known to it. The bootloader in turn requires the \nbin2image\n tool to check the image header for version information, CRC checks etc. So, we will need to build these two additional targets (bootloader and bin2img).\n\n\n\n\nLet's first create bin2img:\n\n\n $ newt target create bin2img\n Creating target bin2img\n Target bin2img successfully created!\n $ newt target set bin2img arch=sim\n Target bin2img successfully set arch to sim\n $ newt target set bin2img compiler=sim\n Target bin2img successfully set compiler to sim\n $ newt target set bin2img project=bin2img\n Target bin2img successfully set project to bin2img\n $ newt target set bin2img compiler_def=debug\n Target bin2img successfully set compiler_def to debug\n $ newt target set bin2 img bsp=hw/bsp/native\n Target bin2img successfully set bsp to hw/bsp/native\n $ newt target show bin2img\n bin2img\n arch=sim\n bsp=hw/bsp/native\n compiler=sim\n compiler_def=debug\n name=bin2img\n project=bin2img\n\n\n\n\n\nAnd then let's create boot_olimex:\n\n\n $ newt target create boot_olimex\n Creating target boot_olimex\n Target boot_olimex successfully created!\n $ newt target set boot_olimex arch=cortex_m4\n Target boot_olimex successfully set arch to cortex_m4\n $ newt target set boot_olimex compiler=arm-none-eabi-m4\n Target boot_olimex successfully set compiler to arm-none-eabi-m4\n $ newt target set boot_olimex project=boot\n Target boot_olimex successfully set project to boot\n $ newt target set boot_olimex compiler_def=optimized\n Target boot_olimex successfully set compiler_def to optimized\n $ newt target set boot_olimex bsp=hw/bsp/olimex_stm32-e407_devboard\n Target boot_olimex successfully set bsp to hw/bsp/olimex_stm32-e407_devboard\n $ newt target show boot_olimex\n boot_olimex\n arch=cortex_m4\n bsp=hw/bsp/olimex_stm32-e407_devboard\n compiler=arm-none-eabi-m4\n compiler_def=optimized\n name=boot_olimex\n project=boot\n\n\n\n\n\n\n\nNow let's build all the three targets now.\n\n\n\n\n $ newt target build bin2img\n Building target bin2img (project = bin2img)\n Building project bin2img\n ...\n Successfully run!\n $ newt target build boot_olimex\n Building target boot_olimex (project = boot)\n Building project boot\n ...\n Successfully run!\n $ newt target build blinky\n Building target blinky (project = blinky)\n Building project blinky\n Suc cessfully run!\n\n\n\n\n\n\n\nGo to the project directory and download the bootloader and the image to flash ... in a flash! \n\n\n\n\n $ cd ~/dev/larva/project/blinky/bin/blinky\n $ newt target download boot_olimex\n Downloading with ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh\n $ newt target download blinky\n Downloading with ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh\n\n\n\n\n\n\n\n\n\nVoil\u00e0! The LED should be blinking! Success!\n\n\n\n\n\n\nBut wait...not so fast. let's double check that it is indeed booting from flash and making the LED blink from the image in flash. Pull the USB cable off the Olimex JTAG adaptor, severing the debug connection to the JTAG port. Next power off the Olimex board by pulling out the USB cable from the board. Wait for a couple of seconds and plug the USB cable back to the board. \n\n\n\n\n\n\nThe LED light will start blinking aga in. Success!\n\n\nNote #1: If you want to download the image to flash and a gdb session opened up, use \nnewt target debug blinky\n instead of \nnewt target download blinky\n.\n\n\n $ newt target debug blinky\n Debugging with ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh blinky\n Debugging ~/dev/larva/project/blinky/bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 or later \nhttp://gnu.org/licenses/gpl.html\n\n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x08000250 msp: 0x10010000\n Info : accepting \ngdb\n connection from 3333\n Info : device id = 0x10036413\n Info : flash size = 1024kbytes\n Reset_Handler () at startup_STM32F40x .s:199\n 199 ldr r1, =__etext\n (gdb)\n\n\n\n\n\nNote #2: If you want to erase the flash and load the image again you may use the following commands from within gdb. \nflash erase_sector 0 0 x\n tells it to erase sectors 0 through x. When you ask it to display (in hex notation) the contents of the sector starting at location 'lma,' you should see all f's. The memory location 0x8000000 is the start or origin of the flash memory contents and is specified in the olimex_stm32-e407_devboard.ld linker script. The flash memory locations is specific to the processor.\n\n\n (gdb) monitor flash erase_sector 0 0 4\n erased sectors 0 through 4 on flash bank 0 in 2.296712s\n (gdb) monitor mdw 0x08000000 16\n 0x08000000: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000000: ffffffff ffffffff ffffffff ffffffff fffff fff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (gdb) monitor flash info 0\n\n\n\n\n\nConclusion\n\n\nCongratulations! You have now tried out a project on actual hardware. If this is your first time to embedded systems, this must feel like the best hands-on and low-level \"Hello World\" progam ever. \n\n\nGood, we have more fun tutorials for you to get your hands dirty. Be bold and try other Blinky-like \ntutorials\n.\n\n\nIf you see anything missing or want to send us feeback, please do so by signing up for appropriate mailing lists on our \nCommunity Page\n\n\nKeep on hacking and blinking!", + "text": "Blinky, Your Hello World!\n\n\nObjective\n\n\nLearn how to use packages from a default application repository of Mynewt to build your first \nHello World\n application (Blinky) on a target board. Once built using the \nnewt\n tool, this application will blink the LED lights on the target board. Fun stuff!\n\n\nThis tutorial will guide you to achieve the following, assuming you have already set up the environment on your computer to use Mynewt OS and newt tool:\n\n\n\n\nDownload packages and use tools to create a runtime image for a board to make its LED blink. You have two choices here:\n\n\nDownload an image to SRAM\n, or \n\n\nDownload it to flash\n.\n\n\n\n\n\n\n\n\n\n\n Time Requirement\n: Allow yourself a couple of hours for this project if you are relatively new to embedded systems and playing with development boards. Those jumpers can be pesky!\n\n\n\n\nWhat you need\n\n\n\n\nSTM32-E407 development board from Olimex. You can order it from \nhttp://www.mou ser.com\n, \nhttp://www.digikey.com\n, and other places.\n\n\nARM-USB-TINY-H connector with JTAG interface for debugging ARM microcontrollers (comes with the ribbon cable to hook up to the board)\n\n\nUSB A-B type cable to connect the debugger to your personal computer\n\n\nPersonal Computer with Mac OS (Mac: OS X Yosemite Version 10.10.5) or Linux box (Ubuntu 14.10: Utopic Unicorn)\n\n\nAn account on Github repository and \ngit\n installed on your computer.\n\n\nIt is assumed you have already installed newt tool. \n\n\nIt is assumed you already installed native tools as described \nhere\n\n\n\n\nAlso, we assume that you're familiar with UNIX shells. Let's gets started!\n\n\n\n\nUse SRAM to make LED blink\n\n\nIf you wish to build the image to run from the onboard SRAM on Olimex board, follow the steps below:\n\n\n\n\nPrepare the Software\n\n\n\n\nMake sure the PATH environment variable includes the $HOME/dev/go/bin directory. \n\n\n\n\n\n\nCreate a project.\n\n\nCreate a new projec t to hold your work. For a deeper understanding, you can read about project creation in \n\nGet Started -- Creating Your First Project\n\nor just follow the commands below.\n\n\n $ mkdir ~/dev\n $ cd ~/dev\n $ newt new myproj\n Downloading project skeleton from apache/incubator-mynewt-blinky...\n Installing skeleton in myproj...\n Project myproj successfully created.\n\n $\ncd\n myproj\n\n $ newt install -v \n apache-mynewt-core\n Downloading repository description for apache-mynewt-core... success!\n ...\n apache-mynewt-core successfully installed version 0.7.9-none\n\n\n\n\n\n\n\nCreate a target\n\n\nChange directory to ~/dev/core directory and define the \nblinky\n target inside core, using the \nnewt\n tool. Starting with the target name, assign specific aspects of the project, as shown below, to pull the appropriate packages and build the right bundle or list for the board. For example, we set the build_profile, board support package (bsp), and app.\n\n\n $ newt target create blinky\n Target targets/blinky successfully created\n $ newt target set blinky build_profile=debug\n Target targets/blinky successfully set target.compiler_def to debug\n $ newt target set blinky bsp=@apache-mynewt-core/hw/bsp/olimex_stm32-e407_devboard\n Target targets/blinky successfully set target.bsp to ...\n $ newt target set blinky app=@apache-mynewt-core/apps/blinky\n Target targets/blinky successfully set target.app to apps/blinky\n $ newt target show blinky\n targets/boot_olimex\n app=apps/blinky\n bsp=hw/bsp/olimex_stm32-e407_devboard\n build_profile=debug\n\n\n\n\n\n\n\nBuild the image\n\n\nNext, let's build the image with the above values assigned. By default, the linker script within the \nhw/bsp/olimex_stm32-e407_devboard\n package builds an image for flash memory, which we don't want; instead, we want an image for the SRAM, so you need to switch that script with \nrun_from_sram.ld\n . \n\n\n\n(We are working to simplify this scheme whereby an executable for a project will correctly elect the linker scripts and generate the relevant image. For example, the scheme will key on project identity such as bootloader, RAM, Flash (default) and build accordingly.) \n.\n\n\nAfer you build the target, you can find the executable \nblinky.elf\n in the project directory \n~/dev/core/bin/blinky/apps/blinky/.\n \n\n\n $ cd ~/dev/core/hw/bsp/olimex_stm32-e407_devboard\n $ diff olimex_stm32-e407_devboard.ld run_from_sram.ld\n (some diff will be displayed)\n $ cp run_from_sram.ld olimex_stm32-e407_devboard.ld\n $ cd ~/dev/core\n $ newt build blinky\n Compiling case.c\n Compiling suite.c\n ...\n Linking blinky.elf\n App successfully built:~/dev/core/bin/blinky/apps/blinky/blinky.elf \n $ ls bin/blinky/apps/blinky/\n blinky.elf blinky.elf.bin blinky.elf.cmd \n blinky.elf.lst blinky.elf.map\n\n\n\n\n\n\n\nPrepare the ha rdware to boot from embedded SRAM\n\n\n\n\nLocate the boot jumpers on the board.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nB1_1/B1_0 and B0_1/B0_0 are PTH jumpers. Note that because the markings on the board may not always be accurate, when in doubt, you should always refer to the manual for the correct positioning. Since the jumpers are a pair, they should move together, and as such, the pair is responsible for the boot mode when bootloader is present. \nTo locate the bootloader, the board searches in three places: User Flash Memory, System Memory or the Embedded SRAM. For this Blinky project, we will configure it to boot from SRAM by jumpering \nB0_1\n and \nB1_1\n.\n\n\n\n\n\n\nConnect USB-OTG#2 in the picture above to a USB port on your computer (or a powered USB hub to make sure there is enough power available to the board). \n\n\n\n\n\n\nThe red PWR LED should be lit. \n\n\n\n\n\n\nConnect the JTAG connector to the SWD/JTAG interface on the board. The other end of the cable should be c onnected to the USB port or hub of your computer.\n\n\n\n\n\n\n\n\nLet's Go!\n\n\n\n\nEnsure that you are in the blinky project directory with the \nblinky.elf\n executable. Run the debug command in the \nnewt\n tool. You'll see some status messages as shown below. In case you need to halt the debugging session, you can issue an \n-c \"reset halt\"\n command.\n\n\n\n\n $ cd ~/dev/core\n $ newt debug blinky\n Debugging with ~/dev/core/hw/bsp/olimex_...\n Debugging ~/dev/core/project/blinky/bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 \nhttp://gnu.org/licenses/gpl.html\n\n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x080003c0 msp: 0x10010000\n Info : accepting \ngdb\n connection on tcp/3333\n Info : device id = 0x10036413\n I nfo : flash size = 1024kbytes\n\n\n\n\n\n\n\nCheck the value of the msp (main service pointer) register. If it is not 0x10010000 as indicated above, you will have to manually set it after you open the gdb tool and load the image on it. For example, \n\n\n (gdb) set $\nmsp\n=0x10010000\n\n\n\n\n\n\n\nNow load the image and type \"c\" or \"continue\" from the GNU debugger. \n\n\n (gdb) load ~/dev/core/bin/blinky/apps/blinky/blinky.elf \n Loading section .text, size 0x16b88 lma 0x20000000\n Loading section .ARM.exidx, size 0x18 lma 0x20016b88\n Loading section .data, size 0x9ec lma 0x20016ba0\n Start address 0x200004b8, load size 95628\n Transfer rate: 74 KB/sec, 3825 bytes/write.\n (gdb) c\n Continuing.\n\n\n\n\n\n\n\nVoil\u00e0! The board's LED should be blinking at 1 Hz. Success!\n\n\n\n\n\n\nUse flash to make LED blink\n\n\nIf you wish to build the image to run from the onboard flash memory on Olimex board, follow the steps below:\n\n\n\n\n\n\nConfigure the board to boot from flash by moving the two jumpers together to \nB0_0\n and \nB1_0\n. Refer to the pictures of the board under the section titled \n\"Prepare the hardware to boot from embedded SRAM\"\n.\n\n\nYou will have to reset the board once the image is uploaded to it.\n\n\n\n\n\n\nIf you skipped the first option for the project \n(downloading an image to SRAM)\n, then skip this step. Otherwise, continue with this step. \n\n\n\n\n\n\nBy default, the linker script (\nolimex_stm32-e407_devboard.ld\n) is configured to run from bootloader and flash. However, if you first ran the image from SRAM you had changed \nolimex_stm32-e407_devboard.ld\n to match \nrun_from_sram.ld\n. You will, therefore, return to defaults with \nolimex_stm32-e407_devboard.ld\n linker script matching the contents of 'run_from_loader.ld'. Return to the project directory.\n\n\n $ cd ~/dev/core/hw/bsp/olimex_stm32-e407_devboard\n $ diff olimex_stm32-e407_devboar d.ld run_from_sram.ld\n $ diff olimex_stm32-e407_devboard.ld run_from_loader.ld\n (some diff will be displayed)\n $ cp run_from_loader.ld olimex_stm32-e407_devboard.ld\n $ cd ~/dev/core\n\n\n\n\n\n\n\n\n\nIn order to run the image from flash, you need to build the bootloader as well. The bootloader does the initial set up of the Olimex board and then transfers control to the image stored at a location in flash known to it. \n\n\n\n\nLet\ns create boot_olimex:\n\n```no-highlight\n $ newt target create boot_olimex\n Creating target boot_olimex\n Target boot_olimex successfully created!\n $ newt target set boot_olimex build_profile=optimized\n Target boot_olimex successfully set compiler_def to optimized\n $ newt target set boot_olimex @apache-mynewt-core/hw/bsp/olimex_stm32-e407_devboard\n Target boot_olimex successfully set bsp to ...\n $ newt target set boot_olimex app=@apache-mynewt-core/apps/boot\n Target targets/boot_olimex successfully set target.app to apps/boot\n $ newt target show boot_olimex\n targets/boot_olimex\n app=app=@apache-mynewt-core/apps/boot\n bsp=@apache-mynewt-core/hw/bsp/olimex_stm32-e407_devboar\n build_profile=optimized\n\n\n\n\n\n\n\n\n\nNow let's build both targets now.\n\n\n\n\n $ newt build boot_olimex\n ...\n App successfully built: ~/dev/core/bin/boot_olimex/apps/boot/boot_olimex.elf\n $ newt build blinky\n ...\n Linking blinky.elf\n App successfully built: ~/dev/core/bin/blinky/apps/blinky/blinky.elf\n\n\n\n\n\n\n\n\n\nCreate the blinky image and download the bootloader and the image to flash ... in a flash! \nWhen creating an image, you can assign a version number to your image; here we use '1.2.3'\n\n\n\n\n $ newt create-image blinky 1.2.3\n App image successfully generated: ~/dev/core/bin/blinky/apps/blinky/blinky.img\n Build manifest: ~/dev/core/bin/blinky/apps/blinky/manifest.json\n $ newt load boot_olimex\n Downloading ~/de v/core/bin/boot_olimex/apps/boot/boot.elf.bin to 0x08000000\n Open On-Chip Debugger 0.9.0 (2015-11-15-13:10)\n ...\n shutdown command invoked\n $ newt load blinky\n Downloading ~/dev/core/bin/blinky/apps/blinky/blinky.img to 0x08020000\n Open On-Chip Debugger 0.9.0 (2015-11-15-13:10)\n ...\n shutdown command invoked\n\n\n\n\n\n\n\n\n\nVoil\u00e0! The LED should be blinking! Success!\n\n\n\n\n\n\nBut wait...not so fast.\n Let's double check that it is indeed booting from flash and making the LED blink from the image in flash. Pull the USB cable off the Olimex JTAG adaptor, severing the debug connection to the JTAG port. Next power off the Olimex board by pulling out the USB cable from the board. Wait for a couple of seconds and plug the USB cable back to the board. \n\n\nThe LED light will start blinking again. Success!\n\n\nNote #1:\n If you want to download the image to flash and a gdb session opened up, use \nnewt debug blinky\n after \nnewt download blinky \n.\n\n\n $ newt debug blinky\n Debugging with ~/dev/core/hw/bsp/olimex_stm32-e407_...\n Debugging ~/dev/core/project/blinky/bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 \nhttp://gnu.org/licenses/gpl.html\n\n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x08000250 msp: 0x10010000\n Info : accepting \ngdb\n connection from 3333\n Info : device id = 0x10036413\n Info : flash size = 1024kbytes\n Reset_Handler () at startup_STM32F40x.s:199\n 199 ldr r1, =__etext\n (gdb)\n\n\n\n\n\n\n\nNote #2:\n If you want to erase the flash and load the image again you may use the following commands from within gdb. \nflash erase_sector 0 0 x\n tells it to erase sectors 0 through x. When you ask it to display (in hex notation) the contents of the sector starting at location 'lma,' you should see all f's. The memory location 0x8000000 is the start or origin of the flash memory contents and is specified in the olimex_stm32-e407_devboard.ld linker script. The flash memory locations is specific to the processor.\n\n\n (gdb) monitor flash erase_sector 0 0 4\n erased sectors 0 through 4 on flash bank 0 in 2.296712s\n (gdb) monitor mdw 0x08000000 16\n 0x08000000: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000000: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (gdb) monitor flash info 0\n\n\n\n\n\nConclusion\n\n\nCongratulations! You have now tried out a project on actual hardware. If this is your first time to embedded systems, this must feel like the best hands-on and low-level \"Hello World\" program ever. \n\n\nGood, we have more fun tutorials for you to get your hands dirty. Be bold and try other Blinky-like \ntutorials\n.\n\n\nIf you see anything missing or want to send us feedback, please do so by signing up for appropriate mailing lists on our \nCommunity Page\n\n\nKeep on hacking and blinking!", "title": "Blinky on Olimex" }, { @@ -257,12 +257,12 @@ }, { "location": "/os/tutorials/olimex/#objective", - "text": "Learn how to use packages from a default application repository of Mynewt to build your first Hello World application (Blinky) on a target board. Once built using newt tool, this application will blink the LED lights on the target board. Fun stuff! This tutorial will guide to achieve the following, assuming you have already set up the environment on your computer to use Mynewt OS and newt tool: Download packages and use tools to create a runtime image for a board to make its LED blink. You have two choices here:\n * Download an image to SRAM , or \n * Download it to flash . Time Requirement : Allow yourself a couple of hours for this project if you are relatively new to embedded systems and playing with development boards. Those jumpers can be pesky!", + "text": "Learn how to use packages from a default application repository of Mynewt to build your first Hello World application (Blinky) on a target board. Once built using the newt tool, this application will blink the LED lights on the target board. Fun stuff! This tutorial will guide you to achieve the following, assuming you have already set up the environment on your computer to use Mynewt OS and newt tool: Download packages and use tools to create a runtime image for a board to make its LED blink. You have two choices here: Download an image to SRAM , or Download it to flash . Time Requirement : Allow yourself a couple of hours for this project if you are relatively new to embedded systems and playing with development boards. Those jumpers can be pesky!", "title": "Objective" }, { "location": "/os/tutorials/olimex/#what-you-need", - "text": "STM32-E407 development board from Olimex. You can order it from http://www.mouser.com , http://www.digikey.com , and other places. ARM-USB-TINY-H connector with JTAG interface for debugging ARM microcontrollers (comes with the ribbon cable to hook up to the board) USB A-B type cable to connect the debugger to your personal computer Personal Computer with Mac OS (Mac: OS X Yosemite Version 10.10.5) or Linux box (Ubuntu 14.10: Utopic Unicorn) An account on Github repository and git installed on your computer. It assumed you already installed native tools described here Also, we assume that you're familiar with UNIX shells. Let's gets started!", + "text": "STM32-E407 development board from Olimex. You can order it from http://www.mouser.com , http://www.digikey.com , and other places. ARM-USB-TINY-H connector with JTAG interface for debugging ARM microcontrollers (comes with the ribbon cable to hook up to the board) USB A-B type cable to connect the debugger to your personal computer Personal Computer with Mac OS (Mac: OS X Yosemite Version 10.10.5) or Linux box (Ubuntu 14.10: Utopic Unicorn) An account on Github repository and git installed on your computer. It is assumed you have already installed newt tool. It is assumed you already installed native tools as described here Also, we assume that you're familiar with UNIX shells. Let's gets started!", "title": "What you need" }, { @@ -271,28 +271,43 @@ "title": "Use SRAM to make LED blink" }, { - "location": "/os/tutorials/olimex/#preparing-the-software", - "text": "Make sure the PATH environment variable includes the $HOME/dev/go/bin directory. If you have cloned the larva repository for the simulator test in the previous section, you can skip this step. Otherwise, you have to create a repository for the project. Go to ~/dev and clone the larva repository from the apache git repository into a local directory named larva . $ cd ~/dev \n $ git clone https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva.git larva\n $ ls\n\n go larva\n $ ls larva\n DISCLAIMER NOTICE app.yml compiler hw net project sys\n LICENSE README.md autotargets fs libs pkg-list.yml scripts Change directory to ~dev/larva directory and build the blinky project inside larva, using the newt tool. Starting with the target name, assign specific aspects of the project, as shown below, to pull the appropriate packages and build the right bundle or lis t for the board. For example, we set the architecture (arch), compiler, board support package (bsp), project, and compiler mode. (Remember to prefix each command with \"newtvm\" if you are executing the newt command in a Linux virtual machine on your Windows box!) $ newt target create blinky\n Creating target blinky\n Target blinky sucessfully created!\n $ newt target set blinky arch=cortex_m4\n Target blinky successfully set arch to arm\n $ newt target set blinky compiler=arm-none-eabi-m4\n Target blinky successfully set compiler to arm-none-eabi-m4\n $ newt target set blinky project=blinky\n Target blinky successfully set project to blinky\n $ newt target set blinky compiler_def=debug\n Target blinky successfully set compiler_def to debug\n $ newt target set blinky bsp=hw/bsp/olimex_stm32-e407_devboard\n Target blinky successfully set bsp to hw/bsp/olimex_stm32-e407_devboard\n $ newt target show blinky\n blinky\n arch=cortex_m4\n bsp=hw/bsp/olimex_stm32-e407_devboard\n compiler=arm-none-eabi-m4\n compiler_def=debug\n name=blinky\n project=blinky Next, let's build the image with the above values assigned. By default, the linker script within the hw/bsp/olimex_stm32-e407_devboard package builds an image for flash memory, which we don't want; instead, we want an image for the SRAM, so you need to switch that script with run_from_sram.ld . \n(We are working to simplify this scheme whereby an executable for a project will correctly elect the linker scripts and generate the relevant image. For example, the scheme will key on project identity such as bootloader, RAM, Flash (default) and build accordingly. .) Afer you build the target, you can find the executable *blinky.elf* in the project directory *~/dev/larva/project/blinky/bin/blinky.* $ cd ~/dev/larva/hw/bsp/olimex_stm 32-e407_devboard\n $ diff olimex_stm32-e407_devboard.ld run_from_sram.ld\n (some diff will be displayed)\n $ cp run_from_sram.ld olimex_stm32-e407_devboard.ld\n $ cd ~/dev/larva/project/blinky/\n $ newt target build blinky\n Building target blinky (project = blinky)\n Compiling case.c\n Compiling suite.c\n ...\n Successfully run!\n $ ls bin/blinky\n blinky.elf blinky.elf.bin blinky.elf.cmd blinky.elf.lst blinky.elf.map Check if you have all the scripts needed to launch OpenOCD and interact with the project's specific hardware. Depending on your system (Ubuntu or Windows) you may already have the scripts in your /usr/share/openocd/scripts/ directory, as they may have been part of the openocd download. If they exist, you are all set and can proceed to prepare the hardware. Otherwise check the ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard directory for a file named f407.cfg . Used by OpenOCD, this config enables us to interact with this specific hardware. You are all set if you see the file. $ ls ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard\n bin include olimex_stm32-e407_devboard_download.sh run_from_loader.ld\n boot-olimex_stm32-e407_devboard.ld olimex_stm32-e407_devboard.ld pkg.yml run_from_sram.ld\n f407.cfg olimex_stm32-e407_devboard_debug.sh run_from_flash.ld src", - "title": "Preparing the Software" + "location": "/os/tutorials/olimex/#prepare-the-software", + "text": "Make sure the PATH environment variable includes the $HOME/dev/go/bin directory.", + "title": "Prepare the Software" + }, + { + "location": "/os/tutorials/olimex/#create-a-project", + "text": "Create a new project to hold your work. For a deeper understanding, you can read about project creation in Get Started -- Creating Your First Project \nor just follow the commands below. $ mkdir ~/dev\n $ cd ~/dev\n $ newt new myproj\n Downloading project skeleton from apache/incubator-mynewt-blinky...\n Installing skeleton in myproj...\n Project myproj successfully created.\n\n $ cd myproj\n\n $ newt install -v \n apache-mynewt-core\n Downloading repository description for apache-mynewt-core... success!\n ...\n apache-mynewt-core successfully installed version 0.7.9-none", + "title": "Create a project." + }, + { + "location": "/os/tutorials/olimex/#create-a-target", + "text": "Change directory to ~/dev/core directory and define the blinky target inside core, using the newt tool. Starting with the target name, assign specific aspects of the project, as shown below, to pull the appropriate packages and build the right bundle or list for the board. For example, we set the build_profile, board support package (bsp), and app. $ newt target create blinky\n Target targets/blinky successfully created\n $ newt target set blinky build_profile=debug\n Target targets/blinky successfully set target.compiler_def to debug\n $ newt target set blinky bsp=@apache-mynewt-core/hw/bsp/olimex_stm32-e407_devboard\n Target targets/blinky successfully set target.bsp to ...\n $ newt target set blinky app=@apache-mynewt-core/apps/blinky\n Target targets/blinky successfully set target.app to apps/blinky\n $ newt target show blinky\n targets/boot_olimex\n app=apps/blinky\n bsp=hw/bsp/olimex_stm32-e407_devboard\n build_profile=debug", + "title": "Create a target" + }, + { + "location": "/os/tutorials/olimex/#build-the-image", + "text": "Next, let's build the image with the above values assigned. By default, the linker script within the hw/bsp/olimex_stm32-e407_devboard package builds an image for flash memory, which we don't want; instead, we want an image for the SRAM, so you need to switch that script with run_from_sram.ld . \n(We are working to simplify this scheme whereby an executable for a project will correctly elect the linker scripts and generate the relevant image. For example, the scheme will key on project identity such as bootloader, RAM, Flash (default) and build accordingly.) . Afer you build the target, you can find the executable blinky.elf in the project directory ~/dev/core/bin/blinky/apps/blinky/. $ cd ~/dev/core/hw/bsp/olimex_stm32-e407_devboard\n $ diff olimex_stm32-e407_devboard.ld run_from_sram.ld\n (some diff will be displayed)\n $ cp run_from_sram.ld olimex_stm32-e407_devboard.ld\n $ cd ~/dev/core\n $ newt build blinky\n Compiling cas e.c\n Compiling suite.c\n ...\n Linking blinky.elf\n App successfully built:~/dev/core/bin/blinky/apps/blinky/blinky.elf \n $ ls bin/blinky/apps/blinky/\n blinky.elf blinky.elf.bin blinky.elf.cmd \n blinky.elf.lst blinky.elf.map", + "title": "Build the image" }, { "location": "/os/tutorials/olimex/#prepare-the-hardware-to-boot-from-embedded-sram", - "text": "Locate the boot jumpers on the board. B1_1/B1_0 and B0_1/B0_0 are PTH jumpers. Note that because the markings on the board may not always be accurate, when in doubt, you should always refer to the manual for the correct positioning. Since the jumpers are a pair, they should move together, and as such, the pair is responsible for the boot mode when bootloader is present. \nTo locate the bootloader, the board searches in three places: User Flash Memory, System Memory or the Embedded SRAM. For this Blinky project, we will configure it to boot from SRAM by jumpering B0_1 and B1_1 . Connect USB-OTG#2 in the picture above to a USB port on your computer (or a powered USB hub to make sure there is enough power available to the board). The red PWR LED should be lit. Connect the JTAG connector to the SWD/JTAG interface on the board. The other end of the cable should be connected to the USB port or hub of your computer.", + "text": "Locate the boot jumpers on the board. B1_1/B1_0 and B0_1/B0_0 are PTH jumpers. Note that because the markings on the board may not always be accurate, when in doubt, you should always refer to the manual for the correct positioning. Since the jumpers are a pair, they should move together, and as such, the pair is responsible for the boot mode when bootloader is present. \nTo locate the bootloader, the board searches in three places: User Flash Memory, System Memory or the Embedded SRAM. For this Blinky project, we will configure it to boot from SRAM by jumpering B0_1 and B1_1 . Connect USB-OTG#2 in the picture above to a USB port on your computer (or a powered USB hub to make sure there is enough power available to the board). The red PWR LED should be lit. Connect the JTAG connector to the SWD/JTAG interface on the board. The other end of the cable should be connected to the USB port or hub of your computer.", "title": "Prepare the hardware to boot from embedded SRAM" }, { "location": "/os/tutorials/olimex/#lets-go", - "text": "Ensure that you are in the blinky project directory with the blinky.elf executable. Run the debug command in the newt tool. You'll see some status messages as shown below. In case you need to halt the debugging session, you can issue an -c \"reset halt\" command. $ cd ~/dev/larva/project/blinky/bin/blinky\n $ newt target debug blinky\n Debugging with /Users/aditihilbert/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh blinky\n Debugging /Users/aditihilbert/dev/larva/project/blinky/bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html \n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x2000025 0 msp: 0x10010000\n Info : accepting gdb connection from 3333\n Info : device id = 0x10036413\n Info : flash size = 1024kbytes\n Reset_Handler () at startup_STM32F40x.s:199\n 199 ldr r1, =__etext Check the value of the msp (main service pointer) register. If it is not 0x10010000 as indicated above, you will have to manually set it after you open the gdp tool and load the image on it. For example, (gdb) set $ msp =0x10010000 Now load the image and type \"c\" or \"continue\" from the GNU debugger. (gdb) load ~/dev/larva/project/blinky/bin/blinky/blinky.elf \n Loading section .text, size 0x4294 lma 0x20000000\n Loading section .ARM.extab, size 0x24 lma 0x20004294\n Loading section .ARM.exidx, size 0xd8 lma 0x200042b8\n Loading section .data, size 0x874 lma 0x20004390\n Start address 0x20000250, load size 19460\n Transfer rate: 81 KB/sec, 2432 bytes/write.\n (gdb) c \n Continuing. Voil\u00e0! The board's LED should be blinking at 1 Hz. Success!", + "text": "Ensure that you are in the blinky project directory with the blinky.elf executable. Run the debug command in the newt tool. You'll see some status messages as shown below. In case you need to halt the debugging session, you can issue an -c \"reset halt\" command. $ cd ~/dev/core\n $ newt debug blinky\n Debugging with ~/dev/core/hw/bsp/olimex_...\n Debugging ~/dev/core/project/blinky/bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 http://gnu.org/licenses/gpl.html \n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x080003c0 msp: 0x10010000\n Info : accepting gdb connection on tcp/3333\n Info : device id = 0x10036413\n Info : flash size = 1024kbytes Check the value of the msp (main service pointer) register. If it is not 0x10010000 as indicated above, you will have to manually set it after you open the gdb tool and load the image on it. For example, (gdb) set $ msp =0x10010000 Now load the image and type \"c\" or \"continue\" from the GNU debugger. (gdb) load ~/dev/core/bin/blinky/apps/blinky/blinky.elf \n Loading section .text, size 0x16b88 lma 0x20000000\n Loading section .ARM.exidx, size 0x18 lma 0x20016b88\n Loading section .data, size 0x9ec lma 0x20016ba0\n Start address 0x200004b8, load size 95628\n Transfer rate: 74 KB/sec, 3825 bytes/write.\n (gdb) c\n Continuing. Voil\u00e0! The board's LED should be blinking at 1 Hz. Success!", "title": "Let's Go!" }, { "location": "/os/tutorials/olimex/#use-flash-to-make-led-blink", - "text": "If you wish to build the image to run from the onboard flash memory on Olimex board, follow the steps below: Configure the board to boot from flash by moving the two jumpers together to B0_0 and B1_0 . Refer to the pictures of the board under the section titled \"Prepare the hardware to boot from embedded SRAM\" . You will have to reset the board once the image is uploaded to it. If you skipped the first option for the project (downloading an image to SRAM) , then skip this step. Otherwise, continue with this step. By default, the linker script ( olimex_stm32-e407_devboard.ld ) is configured to run from bootloader and flash. However, if you first ran the image from SRAM you had changed olimex_stm32-e407_devboard.ld to match run_from_sram.ld . You will, therefore, return to defaults with olimex_stm32-e407_devboard.ld linker script matching the contents of 'run_from_loader.ld'. Return to the project directory. $ cd ~/dev/larva/hw/bsp/ol imex_stm32-e407_devboard\n $ diff olimex_stm32-e407_devboard.ld run_from_sram.ld\n $ diff olimex_stm32-e407_devboard.ld run_from_loader.ld\n (some diff will be displayed)\n $ cp run_from_loader.ld olimex_stm32-e407_devboard.ld\n $ cd ~/dev/larva/project/blinky/bin/blinky In order to run the image from flash, you need to build the bootloader as well. The bootloader does the initial set up of the Olimex board and then transfers control to the image stored at a location in flash known to it. The bootloader in turn requires the bin2image tool to check the image header for version information, CRC checks etc. So, we will need to build these two additional targets (bootloader and bin2img). Let's first create bin2img: $ newt target create bin2img\n Creating target bin2img\n Target bin2img successfully created!\n $ newt target set bin2img arch=sim\n Target bin2img successfully set arch to sim\n $ newt targe t set bin2img compiler=sim\n Target bin2img successfully set compiler to sim\n $ newt target set bin2img project=bin2img\n Target bin2img successfully set project to bin2img\n $ newt target set bin2img compiler_def=debug\n Target bin2img successfully set compiler_def to debug\n $ newt target set bin2img bsp=hw/bsp/native\n Target bin2img successfully set bsp to hw/bsp/native\n $ newt target show bin2img\n bin2img\n arch=sim\n bsp=hw/bsp/native\n compiler=sim\n compiler_def=debug\n name=bin2img\n project=bin2img And then let's create boot_olimex: $ newt target create boot_olimex\n Creating target boot_olimex\n Target boot_olimex successfully created!\n $ newt target set boot_olimex arch=cortex_m4\n Target boot_olimex successfully set arch to cortex_m4\n $ newt target set boot_olimex compil er=arm-none-eabi-m4\n Target boot_olimex successfully set compiler to arm-none-eabi-m4\n $ newt target set boot_olimex project=boot\n Target boot_olimex successfully set project to boot\n $ newt target set boot_olimex compiler_def=optimized\n Target boot_olimex successfully set compiler_def to optimized\n $ newt target set boot_olimex bsp=hw/bsp/olimex_stm32-e407_devboard\n Target boot_olimex successfully set bsp to hw/bsp/olimex_stm32-e407_devboard\n $ newt target show boot_olimex\n boot_olimex\n arch=cortex_m4\n bsp=hw/bsp/olimex_stm32-e407_devboard\n compiler=arm-none-eabi-m4\n compiler_def=optimized\n name=boot_olimex\n project=boot Now let's build all the three targets now. $ newt target build bin2img\n Building target bin2img (project = bin2img)\n Building project bin2img\n ...\n Success fully run!\n $ newt target build boot_olimex\n Building target boot_olimex (project = boot)\n Building project boot\n ...\n Successfully run!\n $ newt target build blinky\n Building target blinky (project = blinky)\n Building project blinky\n Successfully run! Go to the project directory and download the bootloader and the image to flash ... in a flash! $ cd ~/dev/larva/project/blinky/bin/blinky\n $ newt target download boot_olimex\n Downloading with ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh\n $ newt target download blinky\n Downloading with ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh Voil\u00e0! The LED should be blinking! Success! But wait...not so fast. let's double check that it is indeed booting from flash and making the LED blink from the image in flash. Pull the USB cable off the Olime x JTAG adaptor, severing the debug connection to the JTAG port. Next power off the Olimex board by pulling out the USB cable from the board. Wait for a couple of seconds and plug the USB cable back to the board. The LED light will start blinking again. Success! Note #1: If you want to download the image to flash and a gdb session opened up, use newt target debug blinky instead of newt target download blinky . $ newt target debug blinky\n Debugging with ~/dev/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh blinky\n Debugging ~/dev/larva/project/blinky/bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html \n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x08000250 msp: 0x10010000\n Info : accepting gdb connection from 3333\n Info : device id = 0x10036413\n Info : flash size = 1024kbytes\n Reset_Handler () at startup_STM32F40x.s:199\n 199 ldr r1, =__etext\n (gdb) Note #2: If you want to erase the flash and load the image again you may use the following commands from within gdb. flash erase_sector 0 0 x tells it to erase sectors 0 through x. When you ask it to display (in hex notation) the contents of the sector starting at location 'lma,' you should see all f's. The memory location 0x8000000 is the start or origin of the flash memory contents and is specified in the olimex_stm32-e407_devboard.ld linker script. The flash memory locations is specific to the processor. (gdb) monitor flash erase_sector 0 0 4\n erased sectors 0 through 4 on flash bank 0 in 2.296712s\n (gdb) monitor mdw 0x08000000 16\n 0x08000000: ffffffff f fffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000000: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (gdb) monitor flash info 0", + "text": "If you wish to build the image to run from the onboard flash memory on Olimex board, follow the steps below: Configure the board to boot from flash by moving the two jumpers together to B0_0 and B1_0 . Refer to the pictures of the board under the section titled \"Prepare the hardware to boot from embedded SRAM\" . You will have to reset the board once the image is uploaded to it. If you skipped the first option for the project (downloading an image to SRAM) , then skip this step. Otherwise, continue with this step. By default, the linker script ( olimex_stm32-e407_devboard.ld ) is configured to run from bootloader and flash. However, if you first ran the image from SRAM you had changed olimex_stm32-e407_devboard.ld to match run_from_sram.ld . You will, therefore, return to defaults with olimex_stm32-e407_devboard.ld linker script matching the contents of 'run_from_loader.ld'. Return to the project directory. $ cd ~/dev/core/hw/bsp/olime x_stm32-e407_devboard\n $ diff olimex_stm32-e407_devboard.ld run_from_sram.ld\n $ diff olimex_stm32-e407_devboard.ld run_from_loader.ld\n (some diff will be displayed)\n $ cp run_from_loader.ld olimex_stm32-e407_devboard.ld\n $ cd ~/dev/core In order to run the image from flash, you need to build the bootloader as well. The bootloader does the initial set up of the Olimex board and then transfers control to the image stored at a location in flash known to it. Let s create boot_olimex:\n\n```no-highlight\n $ newt target create boot_olimex\n Creating target boot_olimex\n Target boot_olimex successfully created!\n $ newt target set boot_olimex build_profile=optimized\n Target boot_olimex successfully set compiler_def to optimized\n $ newt target set boot_olimex @apache-mynewt-core/hw/bsp/olimex_stm32-e407_devboard\n Target boot_olimex successfully set bsp to ...\n $ newt target set boot_olimex app=@apache-mynewt-core/apps/boot\n Target ta rgets/boot_olimex successfully set target.app to apps/boot\n $ newt target show boot_olimex\n targets/boot_olimex\n app=app=@apache-mynewt-core/apps/boot\n bsp=@apache-mynewt-core/hw/bsp/olimex_stm32-e407_devboar\n build_profile=optimized Now let's build both targets now. $ newt build boot_olimex\n ...\n App successfully built: ~/dev/core/bin/boot_olimex/apps/boot/boot_olimex.elf\n $ newt build blinky\n ...\n Linking blinky.elf\n App successfully built: ~/dev/core/bin/blinky/apps/blinky/blinky.elf Create the blinky image and download the bootloader and the image to flash ... in a flash! \nWhen creating an image, you can assign a version number to your image; here we use '1.2.3' $ newt create-image blinky 1.2.3\n App image successfully generated: ~/dev/core/bin/blinky/apps/blinky/blinky.img\n Build manifest: ~/dev/core/bin/blinky/apps/blinky/manifest.json\n $ newt load boot_olimex\n Downloading ~/dev/core/bin/ boot_olimex/apps/boot/boot.elf.bin to 0x08000000\n Open On-Chip Debugger 0.9.0 (2015-11-15-13:10)\n ...\n shutdown command invoked\n $ newt load blinky\n Downloading ~/dev/core/bin/blinky/apps/blinky/blinky.img to 0x08020000\n Open On-Chip Debugger 0.9.0 (2015-11-15-13:10)\n ...\n shutdown command invoked Voil\u00e0! The LED should be blinking! Success! But wait...not so fast. Let's double check that it is indeed booting from flash and making the LED blink from the image in flash. Pull the USB cable off the Olimex JTAG adaptor, severing the debug connection to the JTAG port. Next power off the Olimex board by pulling out the USB cable from the board. Wait for a couple of seconds and plug the USB cable back to the board. The LED light will start blinking again. Success! Note #1: If you want to download the image to flash and a gdb session opened up, use newt debug blinky after newt download blinky . $ newt debug blinky\n Debugging with ~/ dev/core/hw/bsp/olimex_stm32-e407_...\n Debugging ~/dev/core/project/blinky/bin/blinky/blinky.elf\n GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs\n Copyright (C) 2014 Free Software Foundation, Inc.\n License GPLv3+: GNU GPL version 3 http://gnu.org/licenses/gpl.html \n ...\n (info)\n ...\n target state: halted\n target halted due to debug-request, current mode: Thread \n xPSR: 0x01000000 pc: 0x08000250 msp: 0x10010000\n Info : accepting gdb connection from 3333\n Info : device id = 0x10036413\n Info : flash size = 1024kbytes\n Reset_Handler () at startup_STM32F40x.s:199\n 199 ldr r1, =__etext\n (gdb) Note #2: If you want to erase the flash and load the image again you may use the following commands from within gdb. flash erase_sector 0 0 x tells it to erase sectors 0 through x. When you ask it to display (in hex notation) the contents of the sector starting at location 'lma,' you should see all f's. The memory location 0x8000000 is the start or origin of the flash memory contents and is specified in the olimex_stm32-e407_devboard.ld linker script. The flash memory locations is specific to the processor. (gdb) monitor flash erase_sector 0 0 4\n erased sectors 0 through 4 on flash bank 0 in 2.296712s\n (gdb) monitor mdw 0x08000000 16\n 0x08000000: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000000: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (0x08000020: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff \n (gdb) monitor flash info 0", "title": "Use flash to make LED blink" }, { "location": "/os/tutorials/olimex/#conclusion", - "text": "Congratulations! You have now tried out a project on actual hardware. If this is your first time to embedded systems, this must feel like the best hands-on and low-level \"Hello World\" progam ever. Good, we have more fun tutorials for you to get your hands dirty. Be bold and try other Blinky-like tutorials . If you see anything missing or want to send us feeback, please do so by signing up for appropriate mailing lists on our Community Page Keep on hacking and blinking!", + "text": "Congratulations! You have now tried out a project on actual hardware. If this is your first time to embedded systems, this must feel like the best hands-on and low-level \"Hello World\" program ever. Good, we have more fun tutorials for you to get your hands dirty. Be bold and try other Blinky-like tutorials . If you see anything missing or want to send us feedback, please do so by signing up for appropriate mailing lists on our Community Page Keep on hacking and blinking!", "title": "Conclusion" }, {