Author Topic: One Dollar One Minute ARM Development  (Read 90855 times)

0 Members and 1 Guest are viewing this topic.

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
One Dollar One Minute ARM Development
« on: September 02, 2014, 10:13:01 pm »
By one dollar I mean parts will total $1 and change and by one minute all tools necessary to start coding and flashing can be downloaded and tested in less than 60 seconds. OK, maybe TWO dollars if you're not a great shopper and TWO minutes if you have slow internet. A photo of my STM32 target board is shown below.

Prompted by a request for simple low cost intro to the 32bit world in this thread:

Which ARM does best work to graduate to that has the economy of programming time, as well as the cost conveniences

Threads that got me started with ARM a few months back: http://www.rcgroups.com/forums/showthread.php?t=2154329

Similar to Dannyf's excellent "ghetto" project but with a specific and very common chip and even more basic development tools. I think users who are experienced and satisfied with the somewhat exotic F0 chips will find that thread very useful. However strangely I've found F0 chips and boards cost a little more than F1 in small qty yet without the advantages of 128k flash, 37 I/O, 20k RAM, 3 USARTS and other bonus features. Anyway the plan is to start things off with a description of minimum hardware including hints on best sources for parts then provide the most basic tools for writing code and flashing the chip. If there's interest another stage involving the $5 ICE dongle mentioned in the other thread and easiest approach to debugging/tracing.

The chip is STM32f103c8t6 which seems to be the most popular ARM from a global perspective. This part is installed on 99% of the Discovery boards shipped by ST and a search on Ebay (buy now/lowest cost) for "arm cortex board" will hint to its popularity. Just about the only choice in first few hundred listings. For anyone not so much into DIY those $7 Ebay "minimum development boards" are a great start. A couple jumpers and you are ready to go. Myself and a few friends took a somewhat different, even more minimal, approach to reduce cost. As indicated in the snapshot below chips can be had on Aliexpress for a dollar and change and PCBs for around 30 cents each. To get the best deal it may be necessary to buy more than one at a time but if you are a good shopper the cost can really get down there. It's even possible with coupon to get the boards down to as low as 15 for a dollar (that's not a typo!):

http://www.uxcell.com/15pcs-dual-sides-smd-smt-qfn48-qfn44-05mm-dip-4844-254mm-pcb-adapter-plate-convertor-board-p-601340.html

Construction is very simple, only two wires on the back of the board with 2 pins for power (3.3v) and 2 for download (RX/TX). The only connections needed are available from a generic USB/serial adapter. Two more pins (SWDIO/SWCLK) allow trace capability but those can be added later for anyone who wants to investigate that. Depending on flash tools it might be required to set the BOOT0 signal. My own download program and/or ICE don't require it but the ST flash "demo" utility does. Schematic is attached although the circuit is simply the spec sheet reference design and so basic it's probably not needed.  Notice the board is not much bigger than a quarter.

I've also uploaded two zip files containing minimum tools for creating a program. Download and unzip both into a folder on your PC then type 'a' from command line or click on "A.BAT" (can also be viewed with notepad to see what it does). You'll notice a few new files are present. "T.S" (source) is assembled into a hex file which can be flashed into the chip then it's unassembled back into a human readable LST file as an example of reverse engineering. Both files are finally printed out for verification. You don't need a board to try this. The program is very simple. It increments a register and loops. As an experiment you can try editing the source, for example replacing #1 with #2, and see the effect on output.

VIOLA! (cello too) You've now managed to accomplish something and go where many expert programmers fear to tread. IMO assembly is one of the best introductions for those interested in how a chip really works. Of course there's nothing to stop you from using the full complement of C/IDE setups with this board as you progress up the learning curve.

EDIT: Another ARM platform, LPC this time, is supported with similar approach in reply #3 slot. One for STM8 too in reply slot #5 with a fully functional C compiler attached. Maybe PSOC4 and/or Silabs EFM series coming soon. If anybody knows of other candidates for the $1 one minute club please speak up.



« Last Edit: October 14, 2014, 09:52:54 pm by paulie »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #1 on: September 02, 2014, 10:19:31 pm »
STM32F103 project continued here due to attachment space limit in first post:

First photo shows a somewhat more useful DIY version with all pins being brought out and 8mhz crystal. There's still only two wires needed on the back of the PCB so very easy to build. It's functionally pretty much the same as those Ebay "blue boards" but about 1/4 the cost and a lot smaller. Connections to a USB/serial dongle are shown and BOOT0 set high ready to flash. Note that it's necessary to reset prior to download again and that this jumper must be removed to run a program stand alone. This is a link to the demo ST flash loader utility that works over a serial port: http://www.st.com/web/en/catalog/tools/PF257525. A super simple LED demo program is attached below.

Second photo shows one of the blue boards hooked up to a $5 STlink clone ready for debugging/tracing. BOOT0 must be set opposite (run) compared to serial download for this to work. Warning: BOOT0 and BOOT1 labels are reversed on most of the Ebay boards so watch out for that. One mod was to remove the 2 useless pins next to the reset button so it can be pushed easier.  Another mod I couldn't resist was to re-purpose that pointless power LED to a short cable that can be plugged into any of the pins. For me TX/PA9 is most useful because it can demonstrate either UART output or I/O blinky routines. Also flashes during download. Triple duty! I found the LED wasn't needed on serial download setups because the USB/serial adapter I use already has an onboard LED connected to that pin.

Another zip file (LEDA9_01) is attached that has source and pre-compiled hex for flashing a PA9/TX LED program. It's very simple, only half dozen instructions and can be re-assembled using the tools in first post. When reset in run mode or flashed in boot mode with "user run" box checked the RX LED on the USB/serial adapter will light. If your adapter don't have an LED there then add one to the board from VCC through series resistor to PA9/TX (pin 31).

As requested a third photo is added showing the bottom of the board with more detail on where those 2 wires (power/ground) go. Another photo shows the top of my "no crystal" board with reset button and a RUN/BOOT select switch. Note that the bootloader does not restore defaults but instead leaves many things initialized which can cause the user program to  run when bootloaded but fail when reset in run mode. So it's necessary to set that switch to run (BOOT0 pin low) and reset again to be sure your code works. The button and switch are pretty much essential if you do this a lot. Note that just resetting in boot mode will not run the user program but waits for a new one to be loaded instead.

Westfw has put together an assembly program that not only wiggles IO but shows how to set up the PLL for various system clock speeds. There's a discussion later on here regarding influence of wait states, multipliers, etc.. Very educational for those interested in how these chips REALLY work. Most of the internet C "tutorials" are by those who don't have a clue. Some say you must sacrifice this knowledge for productivity but IMO learning assembler not only allows for both but results in far superior coding skills. Anyway I've attached a version of the westfw file that has been modified to run on the $1 board. Quite a good example for showing what's actually going on under the hood and introducing things like conditionals  and other source directives (pseudo ops). Also his quite useful .asmh include file which would be essential for those interested in serious development since the ST one only works with C. All this compiles with the tools from post number one.

Another gem by westfw is added in here (WESHEL01). This time, in addition to a few more directives, we learn how to do subroutines and pass data. It initializes the UART and sends "hello world" continuously at 115kbps. Very conveniently uses the same pins as the bootloader so all you need do is to fire up Hyperterminal or similar to see the messages. Even without a comm program you can see the LED flicker as characters are sent. Just like the others simply copy to T.S and hit 'a' or click on it.

More helpful hints from westfw in HELLO_ISR.ZIP. We get some code for printing out decimal numbers (WESDEC01.S) and another to show interrupt driven UART (HELLO_ISR.S). Reply #282 has a discussion of some new features. The second purposely uses a lot more ram and as a result uncovered an error in my orignal linker script. A new version of STM32.LD is included here with RAM set to 20k instead of 8k. Also a new version of the .ASMH file has more symbols defined to support the ISR program. Unzip into the same directory as first post then copy one of the new .S files to T.S and hit 'a'. At this point we have a set of tools up to the task for serious ARM development yet not beyond typical hobbyist abilities. A great contribution.

I've attached a new batch file (A.BAT) that not only compiles but can also flash the chip and then run the program with a single key. No need to touch the target board at all anymore. This has major productivity advantages compared to the popular GUI/IDE approach. One requirement is that the STM flash demo utility be installed in a root folder called "STMFLASH". Note that you now need to connect DTR from the USB/serial dongle to pin 7 (nrst) and also put your own port number in place of the "5" in that batch file. Now we can code, download, and run just as easily as with the STM8.

« Last Edit: October 24, 2014, 03:57:18 pm by paulie »
 

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 3705
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #2 on: September 02, 2014, 10:29:39 pm »
I intend to not just link programming/flashing tools but actually attach them here. I think the size is small enough to allow it. Does anyone know what the limit is for uploading a zip file on this forum?

Just click the attachments and other options line and it will tell you:

Allowed file types: doc, gif, jpg, pdf, png, txt, zip, tar, c, h, hex, bas, xls, odt, asm, wav, aiff, wma, mp3, flac
Restrictions: 25 per post, maximum total size 2000KB, maximum individual size 1000KB

Keyboard error: Press F1 to continue.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #3 on: September 02, 2014, 10:55:48 pm »
So I've decided to reserve this slot for the LPC version of my ARM minimum development project. To start things off here's a zip file containing similar files to STM32 in first post but modified for LPC812M101JD20FP which is the lowest cost member of the family. Surprisingly, at a buck and a quarter, it was even cheaper than smaller siblings. A new linker script and slightly modified T.S is provided. Just like before simply copy these files to the same GCC directory used for STM32 and type 'a'.

Sca introduced me to http://www.flashmagictool.com/ which is a very compact and no nonsense programming utility. Just select device, com port, and file and you are ready to go. The photo below shows wiring for my "$1" DIY proto board. All thats needed is TX/RX (P0_4/P0_0) and ground ISP (P0_12).

« Last Edit: October 08, 2014, 10:09:48 pm by paulie »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 14779
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #4 on: September 02, 2014, 11:30:11 pm »
Why not provide a link to ARM's own GCC distribution? https://launchpad.net/gcc-arm-embedded
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #5 on: September 03, 2014, 02:25:37 am »
This slot is reserved for quick and ez STM8 assembler and C programming. I thought of putting this in the "STM32 ghetto" thread then realized that's technically not STM8 either and might be a big mistake in view of rampant asm-phobia there. So attached are zip files containing complete C and assembler toolset for creating STM8 programs. To start notice STM8ASM2 is only 150k! Anyway just unzip into a new folder and hit 'a'.

To flash install STVP in a root folder (http://www.st.com/web/en/catalog/tools/PF210568):
1. Hook up STlink as in the photo. $1 (actually 37 cent) DIY board is shown but one of the $3 Chinese "red boards" works too.
2. Run STVP. Configure hardware=STlink mode=swim device=stm8f003f3 ok
3. File/open (path)t.s19
4. Program/current_tab led toggles 3us

Easily managed in less than a minute including download time. As an after class exercise maybe try using another pin. For example pin 1 instead of pin 2 by changing the #5 to #4.

Someone else (besides me that is!) has expressed interest in STM8 assembly programming so on request I've put together an include file with equates for all the registers. Personally I like to have actual addresses in source with maybe symbolic names as comments. Others are not used to this so a  cut-and-paste from the programming reference and few minutes spent using my emacs editor command recorder came up with this listing (STM8.H).

I've also attached a complete C compiler toolset (SDCC). Remove the TXT extensions and extract both into a folder with 7zip. Type 'a' to compile the hello world demo which transmits continuously at 57kbaud from pin 2 (TX). The batch file also programs the chip automatically using the above SDVP which is expected to be in a root folder by that name. For those who like clicking on pretty menus the GUI procedure above can also be used but IMO just hitting a key is a lot easier and more productive.


« Last Edit: November 17, 2014, 10:38:31 pm by paulie »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 14779
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #6 on: September 03, 2014, 05:45:58 am »
I got the package in 15 seconds so I guess your bacon is safe with that package.  >:D BTW I like you stance to go bare metal.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #7 on: September 03, 2014, 05:49:24 am »
Why not provide a link to ARM's own GCC distribution? https://launchpad.net/gcc-arm-embedded

What an awful page ;-) 

The download section is hidden in the fine print and when you get there is no binary for Mac OSX.
Drain the swamp.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 14779
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #8 on: September 03, 2014, 06:07:01 am »
How do you mean the downloads are hidden on that page? There is a list with downloads on the right for every OS including Macintosh. I'm using Firefox version 31.0
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1332
  • Country: dk
Re: One Dollar One Minute ARM Development
« Reply #9 on: September 03, 2014, 06:15:52 am »
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #10 on: September 03, 2014, 06:54:19 am »
How do you mean the downloads are hidden on that page? There is a list with downloads on the right for every OS including Macintosh. I'm using Firefox version 31.0

It's a list of recently uploaded download that show on my computer with names shorten by '...' such that you cannot tell which is what.
Drain the swamp.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #11 on: September 03, 2014, 06:58:12 am »
The download section is hidden in the fine print and when you get there is no binary for Mac OSX.

Ahem ... Cough..Cough  :-//

https://launchpad.net/gcc-arm-embedded/+download

And the Mac version
https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q2-update/+download/gcc-arm-none-eabi-4_8-2014q2-20140609-mac.tar.bz2


/Bingo

1 What main page link did you use to get to that download page?

2 tar? bz2? This is not the common way to deliver precompiled Mac binaries (see the exe for windows)
Drain the swamp.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 14779
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #12 on: September 03, 2014, 08:10:15 am »
The downloads are on the main page. What kind of browser are you using?
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #13 on: September 03, 2014, 09:37:06 am »
The link to that download page is indeed displayed on that main page. It's labeled "All downloads", on the right side under that big green area with specific download files. Easy enough to find under 10 seconds. That said, the page layout could definitely have been better. Bit messy.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2599
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #14 on: September 03, 2014, 10:10:48 am »
Quote
"arm-none-eabi-as.exe" is the only one over the limit
Are you really seriously proposing that people introduce themselves to ARM using gnu assembler and no include files to symbolically define the peripherals?  (or is there actually a source for individual chip include files?)
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 14779
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #15 on: September 03, 2014, 11:16:34 am »
Quote
"arm-none-eabi-as.exe" is the only one over the limit
Are you really seriously proposing that people introduce themselves to ARM using gnu assembler and no include files to symbolically define the peripherals?  (or is there actually a source for individual chip include files?)
:palm: Hold your horses  ^-^  He's trying to upload the software and just notes this particular file of the entire package is too big.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2599
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #16 on: September 03, 2014, 11:39:14 am »
BTW, before you go buying anonymous STM32F103 boards from random Chinese vendors via eBay, you might want to notice that the official ST STM32L100C Discovery board, with a somewhat more capable chip (256k+16k, "ultra low power") and the complete ST-Link debugging interface, is available from REAL distributors at prices ranging from about $8 (Mouser) to $16 (Newark)
http://www.mouser.com/ProductDetail/STMicroelectronics/STM32L100C-DISCO/?qs=z4bnopryTCJyctHpd%252b9Nrg==
The "Nucleo" boards (Arduino HW-compatible) are also available in several varieties for about $11 (more of a universal price, I think.)
(no "free shipping" from real distributors, though.)

There's got to be SOME price below which it no longer makes sense to go purchasing parts from three places just to save a few bucks.  Especially if you're in it for the learning experience, and don't want to go through that "am I doing it wrong, or is it broken" phase.   IMO, there isn't much excuse not to just spend $20, skip your friday-night-out dinner in favor of a sandwich,and JUST DO IT.

(And it's not just ST.  Freescale, NXP, TI ... they've ALL got ~$20 development boards.   You can get a TI "Connected" Launchpad with 1M code, 256kB RAM, and ethernet for $21...)

(These comments apply to 'learning.'  If you're going to do like paulie and build a dozen quadcopter controllers, then of course if makes sense to use a bare chip and cheap PCB that you can use...)

 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #17 on: September 03, 2014, 12:52:02 pm »
The downloads are on the main page. What kind of browser are you using?

This is what I get on my browser.

1) The Download title is not a link.
2) The file names are truncated and it's not clear if these are all the downloads or just a recent upload list.
3) The link to the downloads pages is in the footprint (and no binary for Mac OSX)

In addition the page is full of arbitrary details.  Not a welcoming page for first time visitors that want to install the tool chain in one minute.

Drain the swamp.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 14779
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #18 on: September 03, 2014, 06:10:20 pm »
You really need new glasses. One of the downloads in the list at 2 says 'mac' in the name  :palm: I doubt that will run on the ancient 68k or PowerPC macs.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline eliocor

  • Supporter
  • ****
  • Posts: 326
  • Country: it
    • rhodiatoce
Re: One Dollar One Minute ARM Development
« Reply #19 on: September 03, 2014, 08:31:28 pm »
Typical MAC user... ;)
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #20 on: September 03, 2014, 08:43:53 pm »
Quote
This is what I get on my browser.

Wow!

No wonder Apple is such a cash cow.

:)
================================
https://dannyelectronics.wordpress.com/
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #21 on: September 03, 2014, 09:47:38 pm »
You really need new glasses. One of the downloads in the list at 2 says 'mac' in the name  :palm: I doubt that will run on the ancient 68k or PowerPC macs.

If didn't say that I couldn't find the downloads, I said that the design of that page is awful.
Drain the swamp.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #22 on: September 03, 2014, 09:58:07 pm »
Schematic and programming demo uploaded to first post.


Are you really seriously proposing that people introduce themselves to ARM using gnu assembler and no include files to symbolically define the peripherals?
:palm: Hold your horses  ^-^  He's trying to upload the software and just notes this particular file of the entire package is too big.

Actually Wes is right. That people introduce themselves to ARM using gnu assembler and no include files is exactly what I'm really seriously proposing. Include files are not required to create a simple program.

My goal here is to show people, even those with no experience whatsoever, how to make a program. Not create a race of uber-coders. My philosophy is that starting out with MINIMUM hardware and MINIMUM software is exactly the most painless way to get into a new platform. Not the fanciest most expensive hardware and most complicated bloated toolset. There's time for that later.

I also think that "cheapest" or "Most popular in an ebay listing" is an excellent indicator of "easiest next step". Those discovery boards are a great bargain but IMO not the best deal for anyone just wanting to check out a new chip. You can't buy one from Mouser for $8. Shipping will double that. At a buck or so (shipped) one can have a dozen of my  DIY version or, for plug-n-play kiddies, a couple of the $6 "blue" boards. No matter the source, considering wait time, having backup in case of mis-step... PRICELESS.

ps. Note that it's not possible to actually attach the Discovery files in a forum like this (we now know how tragically difficult navigating links can be) and nobody will manage to create code in less than a minute. It takes 10x that just to read the "Quick Start Guide".

pps. Personally I find that GCC download page extremely well done. If you want to see real creativity in action check out some of the code repositories like google and github. Bizzare might be an understatement.
« Last Edit: September 04, 2014, 12:19:55 am by paulie »
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 273
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #23 on: September 03, 2014, 10:36:37 pm »
I am not considering your a $1 to get into ARM ... but think your approach , walk before you run is right.... however starting with asm in my experience requires code examples and templates ... truck loads !  code that will not just flash a led , but serial and other comms , interrupt, AD and timer use....  all the building blocks for projects  My electronic logic experience stretches back 40 years although you never stop learning . 

PS we don't all live in the US...   
« Last Edit: September 03, 2014, 10:42:34 pm by 22swg »
Check your tongue, your belly and your lust. Better to enjoy someone else’s madness.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #24 on: September 03, 2014, 10:59:38 pm »
My goal here is to show people, even those with no experience whatsoever, how to make a program. Not create a race of uber-coders.

PS we don't all live in the US...

? ? ? ? ? ? ? ?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf