Author Topic: One Dollar One Minute ARM Development  (Read 93232 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 »
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 3770
  • 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 »
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • 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 »
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • 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.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • 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: 1336
  • 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.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • 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: 2704
  • 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?)
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • 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: 2704
  • 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.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • 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.
 

Online eliocor

  • Supporter
  • ****
  • Posts: 341
  • 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...

? ? ? ? ? ? ? ?
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 273
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #25 on: September 04, 2014, 12:26:21 am »
I had started to cost an $1 ARM here in UK  considering european VAT and exchange rates , shipping  it looked a bit more...  ARM chip is $7 in UK.
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 #26 on: September 04, 2014, 01:17:40 am »
My 10 chips come in letter envelope and PCBs in small chinese "e-pak" envelope. Do they really hit you guys up for import tax on such small items?

I shudder to think what happens with one of those "blue" boards or a Discovery.
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 273
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #27 on: September 04, 2014, 01:37:10 am »
The 20% vat  + post man adds something , sometimes the Chinese sender will put 'gift' on the packet  and it slips through  $14  would be probably end up as  20 GBP . 
Check your tongue, your belly and your lust. Better to enjoy someone else’s madness.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #28 on: September 04, 2014, 01:45:37 am »
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
I would recommend to start in C at least. But you are right: you don't need a heap load of other stuff. A C file (maybe with some macro's to access registers) and a linker description file is all you need to get a project compiled for ARM. IMHO a lot of IDEs obfustigate or hide what the compiler is actually doing.

@22swg: usually there is an minimum amount before they start charging tax. Over here it is €35. But many Chinese just stamp 'gift' on a package.
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 #29 on: September 04, 2014, 02:02:56 am »
@22swg: usually there is an minimum amount before they start charging tax. Over here it is €35. But many Chinese just stamp 'gift' on a package.
You sure about that €35? I thought it was tax free up to €22, as per this page: http://bit.ly/1jaJfNZ
 

Offline janekm

  • Supporter
  • ****
  • Posts: 509
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #30 on: September 04, 2014, 02:13:00 am »
The 20% vat  + post man adds something , sometimes the Chinese sender will put 'gift' on the packet  and it slips through  $14  would be probably end up as  20 GBP .

No VAT or Duty when importing into the UK and the value is < £15: http://www.hmrc.gov.uk/customs/post/buying.htm (note that technically postage has to be included in that).

So long as final delivery is by Royal Mail and the declared value is < £15 (or thereabouts), it's extremely unlikely to get any charges added (our Hackerspace gets literally dozens of envelopes from China a week and never been charged to my knowledge).
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #31 on: September 04, 2014, 02:35:26 am »
Quote
He's trying to upload the software and just notes this particular file of the entire package is too big.
I assumed that arm-...-as would be smaller than arm-...-gcc (which it turns out is not true, apparently.  Which is weird.)
The .h files are typically no tiny marvels of modularity, either.  Typical vendor strategy is to dump out a single .h file defining everything on a chip, for each separate chip part number.  The TI tm4c123gh6pm.h file for the Tiva Launchpad is about 700k.  (It should compress a lot, though.)  (Hmm.  stm32f10x.h is "only" 620kb.)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #32 on: September 04, 2014, 03:00:29 am »
Hmm.  That's interesting.  CMSIS apparently defines a standard format for include files that define a chip's peripherals, even though the internals of such peripherals are outside the scope of CMSIS.  "Though shalt have structure definitions cast to constant addresses", more or less.  Like:
Code: [Select]
typedef struct
{
  __IO uint16_t SR;
  uint16_t  RESERVED0;
  __IO uint16_t DR;
  : // etc
} USART_TypeDef;

//     :

#define USART2_BASE           (APB1PERIPH_BASE + 0x4400)
#define USART3_BASE           (APB1PERIPH_BASE + 0x4800)

//    :

#define USART2              ((USART_TypeDef *) USART2_BASE)
#define USART3              ((USART_TypeDef *) USART3_BASE)
That's fine, I guess.  For C and C++.  But the whole structure is useless to assembler programs!
Are there typically NOT any symbol definition files for programming ARMs in assembler?  Really?

 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #33 on: September 04, 2014, 03:01:05 am »
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?

You can have the in a new github project. Easier browse the file and to track modifications, and it's open to all and you can have the documentation with markdown, images, etc.
Drain the swamp.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #34 on: September 04, 2014, 03:06:45 am »
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.
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 273
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #35 on: September 04, 2014, 04:32:37 am »
Seems to be a currency discrimination going on ?   3 ARMs for ~13GBP ...   Thanks janekm no VAT if <15GBP , if it is Royal Mail will charge 8GBP  fee..
« Last Edit: September 04, 2014, 04:52:08 am 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 #36 on: September 04, 2014, 04:57:07 am »
No, that's perfectly normal for Aliexpress. It's not unusual for prices to vary by a factor of 10. Even 100. Sometimes from the same seller. For example here's the first one that just came up for me without any special search terms:

http://www.aliexpress.com/item/STM32F103C8T6-STM32F103-STM32F-LQFP48-NEW-ORIGINAL-IN-STOCK/529600954.html

These guys are tricky and often depend on careless shopping. Buyer beware!

BTW anybody else notice Ebay is down?
« Last Edit: September 04, 2014, 04:58:55 am by paulie »
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 273
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #37 on: September 04, 2014, 06:18:53 am »
I'm thinking theres a risk of fakes or manufactures failures... where did the 48 pin boards come from please...
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 #38 on: September 04, 2014, 06:42:08 am »
Chinese "fakes" is an urban myth. Due to scale of mfg they would cost 1000 times more than the real thing. Parametric failures also rare. There are "refurbs" though which are highly sought after due to extremely low price and already "burned in". One lot of these f103 I was lucky to pick up for less than half dollar each. Unfortunately very seasonal. Wish I had got more then.

See first post for link to PCB. As low as 15 for a dollar (7 cents ea) with coupon. Also available on Ebay but cost a bit more.

Search is your friend with all these chinese sellers.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 1693
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #39 on: September 04, 2014, 06:58:46 am »
Chinese "fakes" is an urban myth.

In what context, just STM32's or semiconductors in general?  If the latter then you should know that counterfeit semiconductors is a massive problem.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #40 on: September 04, 2014, 07:24:55 am »
Integrated circuits in general but mainly stories about MCUs. Based on personal experience and many other sources of info from sites like Microchip forum, Circuit Cellar, DIY Drones, Avrfreaks etc. Usually just typical internet bull but also morons blaming the seller for their own incompetence. Counterfeit chips is a romantic notion but considering the sources and their credibility very unlikely. Cloned board level products on the other hand is a different story.

You are of course entitled to believe whatever you choose.
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 273
  • Country: gb
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 #42 on: September 04, 2014, 08:04:39 am »
I'm sure exhaustive search on the net can dig up convincing tales and statistics for virtually any argument.

Although tabloids are not my favorite source of reliable information I'm willing to consider that "Consumer Electronics/Parts" are commonly counterfeited. Specially, as I said, PCB products. There are some cases of semiconductors but mainly jellybean parts like caps, resistors, and diodes. For example chinese 1n4007 that are curiously cheaper than the lower voltage 1n4001. Turns out leads use very low gauge copper hence fail the 1 amp spec. As part of the day job I purchase several hundred thousand dollars in parts every year. In last 15 years out of a handful of claims from clients, some few traced to parametric failure but vast majority due to customer abuse.

ps. We all deserve to harbor favorite conspiracy theories and fantasies. This just don't happen to be one of mine. YMMV
« Last Edit: September 04, 2014, 08:12:23 am by paulie »
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 273
  • Country: gb
Re: One Dollar One Minute ARM Development
« Reply #43 on: September 04, 2014, 08:19:00 am »
I recognize your obvious experience  , do you not ask yourself how come $1.30  water is dearer !   
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 #44 on: September 04, 2014, 08:23:24 am »
LOL. I'm not sure what that means but if you are referring to bottled water I never touch the stuff. In several consumer protection assays orders of magnitude higher bacterial count than what comes from the tap.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #45 on: September 04, 2014, 08:06:36 pm »
Hmm.  I think your sample program needs some work before it will work on a CM3 cpu.
Code: [Select]
.thumb
.syntax unified

Does anyone know where I can find a definitive explanation of the gnu assembler syntax for ARM, specifically WRT "op2" operands and thumb2 instructions?  I found some manuals with "fill in with an explanation later", but...
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #46 on: September 05, 2014, 02:15:15 am »
Thanks for that. I'm sure you are a lot more experienced than me in these things and I appreciate the help. There's another bug. Without "pause" clicking on the batch file ran too fast to see so that is fixed too. "MC.BAT" has been added which removes output files similar to "make clean". New GCC zip files have been uploaded with all these corrections. I've also put up a photo of a more useful version of the DIY board in the second post (first is full). It shows the setup for flashing with the ST demo utility which I will document when I get a chance.

The ST programming manual has details on instructions and architecture features: http://code.google.com/p/cortex-ap/source/browse/trunk/Firmware/Doc/CD00228163.pdf  CD00161566.pdf is specific to f103 hardware. CD00171190 register details.

Or just search CD00171190, CD00228163, or CD00161566. I hate those Google/Github type repositories but the no nonsense links are apparently too long for this forum. I'm sure you know but for those that don't right click on "raw" to download.



Op2 is a flexible second operand that can be either a register or a constant. Compared to the 8bit world it's amazing how powerful ARM instructions are with tricks like that and the conditional feature built into most instructions. We all know assembly is not the tool for writing practical programs but I find it fascinating as a learning experience. Huge fun too IMO.
« Last Edit: September 05, 2014, 03:37:45 am by paulie »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #47 on: September 05, 2014, 03:39:27 am »
Quote
I'm sure you are a lot more experienced than me
Well, no.  But it's an interesting exercise.

Quote
The ST programming manual has all the details on instructions
Except that this documents the official ARM instruction syntax, and has examples using the ARM assembler syntax, and that's NOT quite what the gnu assembler actually implements.  gas happily ignores manufacturer syntax in favor of something that is maximally "common" across the architectures that it supports, or is convenient to the C compiler, or something.  As a minor ridiculous example, the comment character in gnu as for ARM is "@" instead of ";"
I was going batty trying to figure out how to get it to accept my blink program (from the ghetto thread) which compiled fine in Keil (official) assembler.  Most of that seems to have been solved by the ".syntax unified" addition (which I'm still not sure is the correct thing for cm3/etc.)  But I still have the gnu assembler generating different code than Keil for "sub r1, r1, #1" instruction, and I don't know why :-(

Here's my contribution; I edited the CMSIS stm32f10x.h file provided by ST to make it usable by the gnu assembler.  This provide the base address of the various peripherals, and the various bit constants for registers, but it doesn't include the offsets of registers within a peripheral (which are implemented via structure definitions in the original.  Mostly, this version replaces #define with .equiv)

Edit 6-sep: new version of .asmh file; now includes GPIO peripheral offsets and better bitvalues.
2nd edit 6-sep: defines for the RCC individual registers.
3rd edit 9-sep: create some macros to allow easier conversion from C structures for ASM offset definitions, and include most of the peripheral data structures from the .h include file.
4th edit 10-sep: new version (including a sample that assembles) attached here: http://www.eevblog.com/forum/microcontrollers/one-dollar-one-minute-arm-development/msg511012/#msg511012
« Last Edit: September 11, 2014, 02:52:02 pm by westfw »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #48 on: September 05, 2014, 11:19:59 pm »
Wow! I really appreciate the work you put into that and certainly anybody else who wants to experiment with ARM assembler will too. An update on any progress you make porting your blink to AS would also be of great interest.

I'm having problems with hex file generation. It's not obvious to me if it's as, objdump, or the linker causing trouble. Apparently the ST flash utility expects an  Extended Linear Address record and zero offset for the code which my script AS is not doing. For example the utility generates "incorrect address" errors trying to flash this version of my demo:

Code: [Select]
:08800000010080E2FEFFFFEA2F
:040000030000800079
:00000001FF

But no problem loading this version from a homebrew assembler:

Code: [Select]
:020000040800F2
:08000000010080E2FEFFFFEAAF
:040000030000800079
:00000001FF

Any hints how to get AS to assemble at zero offset instead of 8000?  I tried .org and that don't help.


 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #49 on: September 05, 2014, 11:55:20 pm »
You need to use a linker descriptor file otherwise LD will use some defaults. It helps to tell LD to also create a map file so you can see which code went where in the memory.
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 #50 on: September 06, 2014, 12:22:38 am »
Success! Those scripts were used a lot in my C projects but never paid much attention to. Anyway just copied the ld file from one of my C directories over then added -T to the cmd line and it worked like a charm. Thanks, Between you and Westf I may have a chance at getting this right after all.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #51 on: September 06, 2014, 02:52:18 am »
It is very difficult to imagine that a beginner starts on those chips in assembly.

To work on a reasonable project on those chips in assembly, you have to be an expert or you have tons of resources (time+money).
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #52 on: September 06, 2014, 11:47:02 am »
$1 is a bit misleading.  You're talking about spending ~$10 for enough stuff to make 10 boards.  Plus at least a USB/Serial cable to connect it to something.   Which is only subtly different, I guess, but still...  (this is not dissimilar from my very first arduino-related purchase.  10 bare board, 5 chips, and an FTDI cable from MDC.  And the fact that I COULD do that was pretty instrumental in my ever becoming involved with Arduino.)

I've ordered some STM32f103c8t6 hardware.  $10 for a pre-built single board shipped from closer than China.  It feels a bit funny, since I already have several ARM-based development boards lying around, but in view of arguments I've already made about the prices, I can hardly complain that it's too much money to spend on an interesting experiment.

Quote
It is very difficult to imagine that a beginner starts on those chips in assembly.
I agree entirely.  Assembly is "not used" in the ARM world.  The chip documentation does not include assembly examples, and community software is not written in assembler (and there's no symbol files for asm, aside from what that nut posted here...)   What assembly you CAN find uses the official ARM syntax, which I've mentioned is not the same as the Gnu assembler syntax.

That said, I think the concept of providing a "reduced" toolset has a lot of validity to it.  A "1-minute download" is unnecessary, but it would be nice not to have to go searching all over the internet for the various pieces needed to get started, an not wind up with a "choose processor" menu containing hundreds of chips.

I wonder if something based on the Arduino download would be a good starting point.  It's already got win/linux/mac versions of a complete compiler toolchain, and its about a 200MB download (even with the complete AVR toolset as well.)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #53 on: September 06, 2014, 04:14:41 pm »
Well, this is crap:
Code: [Select]
#define  GPIO_CRL_MODE3                      ((uint32_t)0x00003000)        /*!< MODE3[1:0] bits (Port x mode bits, pin 3) */
#define  GPIO_CRL_MODE3_0                    ((uint32_t)0x00001000)        /*!< Bit 0 */
#define  GPIO_CRL_MODE3_1                    ((uint32_t)0x00002000)        /*!< Bit 1 */
    :
#define  GPIO_CRL_CNF3                       ((uint32_t)0x0000C000)        /*!< CNF3[1:0] bits (Port x configuration bits, pin 3) */
#define  GPIO_CRL_CNF3_0                     ((uint32_t)0x00004000)        /*!< Bit 0 */
#define  GPIO_CRL_CNF3_1                     ((uint32_t)0x00008000)        /*!< Bit 1 */
Thank you SO much for giving me a bunch of long and meaningless names to refer to the bits used to configure the GPIO ports.  They must REALLY want people to use their peripheral library instead of "bare metal."  Unfortunately, it looks like the peripheral library is pretty questionable as well:
Code: [Select]
#define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00))(I guess it's a good thing that no one actually turns ON those "assert" checks?)

grr...

Edit: I guess it's not quite as bad as I thought, but it doesn't inspire confidence, either...

« Last Edit: September 06, 2014, 04:39:09 pm by westfw »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #54 on: September 07, 2014, 01:41:01 am »
To work on a reasonable project on those chips in assembly, you have to be an expert

Or crazy. Pretty much everyone agrees C is the way to go there but for a quick start to test hardware and getting an understanding of how a chip really works I think ASM can't be beat.  IMO your comment about resources seems way off base. If I'm not mistaken this thread is the first and only time 100% functional tools for creating a program have actually been attached and not just linked.  Many will not even have the courtesy to do that.

And one or two bucks for working hardware is "tons of money"? Hmmmm... Also note that last night I won a bet with a buddy by downloading then creating and verifying a program in less than 40 seconds. True I'm very familiar with the steps involved (hit 'a') but this was phone line internet!

This don't look like "tons of resources (time + money)"  from my viewpoint.

BTW The GCC file in first post has been updated with STM32.ld. That demo program seems to behave just as expected stepping through with GDB/OOCD now.
« Last Edit: September 07, 2014, 01:50:57 am by paulie »
 

Offline leppie

  • Frequent Contributor
  • **
  • Posts: 269
  • Country: za
Re: One Dollar One Minute ARM Development
« Reply #55 on: September 07, 2014, 02:06:14 am »
The STM32 Nucloe range is pretty impressive at just over $10 a pop. http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847

Compared to an Arduino you get a lot more.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #56 on: September 07, 2014, 02:45:25 am »
The STM32 Nucloe range is pretty impressive at just over $10 a pop. http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847

Compared to an Arduino you get a lot more.

Does it come with a single package install IDE that runs on all three major OS's.  ?

It's the overall package that counts.
Drain the swamp.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #57 on: September 07, 2014, 07:35:42 am »
Quote
[for]getting an understanding of how a chip really works I think ASM can't be beat.
Oh, I think you'll get a pretty good understanding of things trying to code in C without libc to back you up :-)

I think what makes this project interesting is that we're learning DIFFERENT things than you learn by throwing up the vendor or hobbyist toolset and coding away with the provided libraries and IDE.  It's an excercise in what tools actually do what, and which ones are needed, and in how crappy (or not) the define files are, and in what's actually happening under the hood of an IDE when you click the "build" button.  (for example, I was SHOCKED that xxx-gcc.exe is about the same size as as xxx-as.exe.  Even supposing that there is a separate xxx-cpp to handle C preprocesing (also "about the same size"), I had still assumed that the C compiler itself would be bigger...  And ah hah!  cc1.exe is out there in the lib directory; apparently not considered a user executable and thus not in the bin directory.  (and yes, it's pretty huge.)
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #58 on: September 07, 2014, 07:45:57 am »
IMHO it would serve many people well if they spend some time on how the build process actually works. Unfortunately they don't even teach that in schools/universities.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline leppie

  • Frequent Contributor
  • **
  • Posts: 269
  • Country: za
Re: One Dollar One Minute ARM Development
« Reply #59 on: September 07, 2014, 07:52:16 am »
Does it come with a single package install IDE that runs on all three major OS's.  ?

It's the overall package that counts.

It support MBED, and normal embedded IDE's. So I would say yes.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #60 on: September 07, 2014, 08:25:30 am »
It's the overall package that counts.
It comes with a free "How to put together your own toolchain" lesson that will serve you well for the rest of your life.

That said, sometimes an easy starting point is nice to have as well. Just so you have a known to work situation, and then you branch out to from that to put together the dev environment you really need. Or you pay $$$ to buy something that is just that. Or is almost that, but not quite. Nothing is ever free. Either you flush time, or you flush money.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #61 on: September 07, 2014, 09:14:20 am »
New .asmh file added in http://www.eevblog.com/forum/microcontrollers/one-dollar-one-minute-arm-development/msg507400/#msg507400

My source code now looks like:

Code: [Select]
.include "stm32f103c8.asmh"
.syntax unified


@ BLINK in ARM Assembler
@ For ST32F103c8t6, perhaps
@ Aug 2014, by Bill Westfield - released to Public Domain.
@
 .equ STACKSIZE, 1024
 .equ HEAPSIZE, 8192

        .globl  __Vectors
Vectors: .word    SRAM_BASE+HEAPSIZE+STACKSIZE @ Top of Stack
.word   __start + 1            @ Reset Handler

@ The program itself.

.equ myport, GPIOA_BASE @ must be portA...
.equ mybit, 6 @ arbitrary bit choice, for now.

_start:
.globl  _start
__start:
ldr r0, =RCC_APB2ENR
ldr r1, [r0] @ old val
orr r1, r1, #RCC_APB2ENR_IOPAEN @@ enable PORTA clk
str r1, [r0]
nop @ Wait for PORTF to get clocked.

initf: mov r1, #((GPIO_MODE_OUT+GPIO_CNF_PP) << (mybit*4))  @@ output bits
ldr r0, =GPIOA_BASE @ GPIO_PORTF
str r1, [r0, #GPIO_CRL_O]  @ set bit to output
mov r2, #(1<<mybit)    @
loop: ldr r1, [r0, #GPIO_ODR_O] @ read DATA reg
eor r1, r2          @ complement bit
str r1, [r0, #GPIO_ODR_O] @ write

mov r1, #(4*1024*1024) @ Delay count

delay: subs r1, r1, #1 @ decrement
bne delay
b loop

.end
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #62 on: September 07, 2014, 09:47:29 am »
I think what makes this project interesting is that we're learning DIFFERENT things than you learn by throwing up the vendor or hobbyist toolset and coding away with the provided libraries and IDE.

Definitely. I've been building controllers with this chip for almost a year but  in the last 48 hours of this thread have picked up more information (and inspiration) than all that time. Several failed attempts involving IAR demo and some other Eclipse based packages did little to arouse my interest. I felt like part of the Human Centipede with first guy connected to the last, recycling the same waste endlessly. It wasnt until starting to play with the inner workings of GCC things got really exciting.

BTW I just tried your program with the new include and got something about RCC-APB2ENR in delay undefined. Have you tried this on real hardware? Did your F103 board arrive yet?

I cant' wait to see how this turns out.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #63 on: September 07, 2014, 03:07:06 pm »
Quote
I just tried your program with the new include and got something about RCC-APB2ENR in delay undefined. Have you tried this on real hardware? Did your F103 board arrive yet?

Ahh.  It turns out I wasn't running my output through the linker.  The as command produced an a.out file, and I assumed that it was done (sort of like the way the c compiler works.)  But apparently not...  I'll upload a new file.

I'm expecting the hardware next week; I only paid extra to get it shipped from the US instead of China, not for "expedited shipping."

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #64 on: September 07, 2014, 04:09:57 pm »
(new asmh uploaded.)

The thing is...  I spent the first six years or so of my career programming almost exclusively in assembly language.  The OS and all the system utilities were written in assembly language, because that was How Things Were Done, on that particular system at that particular time.  And there was a WONDERFUL macro assembler, and a huge set of standardized macros for defining and using higher-level language concepts (structures, local variables, stack frames, looping and conditional code structures..)  And there was a relatively large set of programmers working on similar stuff who would discuss such things.  And the machine language was elegant and cool...  It was great!

If you're coming from an 8-bit microchip PIC environment, you've seen some of this sort of thing (minus the elegant machine language :-))

But ARM doesn't have any of that, as far as I can tell.   It has an assembler designed to assemble code output by a C compiler, and a machine language designed to be used by compilers and efficient to implement in hardware.  And everyone programs it in C.  Writing in assembly language for such a chip is ... ill fated (like the song: "kinda like construction work, with a toothpick for a tool.)
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #65 on: September 07, 2014, 07:54:10 pm »
everyone programs it in C

Not true. There's you and me, so at least two now. Maybe three if you count that fellow in Nyurba. LOL
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #66 on: September 07, 2014, 08:07:41 pm »
Sorry; I program ARMs in C.  I think it's interesting to contemplate some basic programming in asm, and I'm certainly willing to LOOK at the asm produced by the compiler (which seems to be a rare thing; people think they need to be an expert at the asm to learn something by looking at the compiler output.  they're wrong...)  But I have no real interest in actually writing any full programs in ARM asm.  Just the occasional optimization, subroutine, or "educational exercise."
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #67 on: September 07, 2014, 08:29:04 pm »
Ok, so there's just me and maybe that guy in Russia. I'm determined to write something in ASM that works if it kills me. Even if it's just to flash a LED or send a character. Almost everything I've picked up so far comes from reading the list file. After poking a CRLF and fudging the RCC to quell the errors here's what AS thinks you want to do:

Code: [Select]
08000008 <_start>:
 8000008: e59f0038 ldr r0, [pc, #56] ; 8000048 <delay+0xc>
 800000c: e5901000 ldr r1, [r0]
 8000010: e3811004 orr r1, r1, #4
 8000014: e5801000 str r1, [r0]
 8000018: e1a00000 nop ; (mov r0, r0)

0800001c <initf>:
 800001c: e3a01401 mov r1, #16777216 ; 0x1000000
 8000020: e59f0024 ldr r0, [pc, #36] ; 800004c <delay+0x10>
 8000024: e5801000 str r1, [r0]
 8000028: e3a02040 mov r2, #64 ; 0x40

0800002c <loop>:
 800002c: e590100c ldr r1, [r0, #12]
 8000030: e0211002 eor r1, r1, r2
 8000034: e580100c str r1, [r0, #12]
 8000038: e3a01501 mov r1, #4194304 ; 0x400000

0800003c <delay>:
 800003c: e2511001 subs r1, r1, #1
 8000040: 1afffffd bne 800003c <delay>
 8000044: eafffff8 b 800002c <loop>
 8000048: 00001234 andeq r1, r0, r4, lsr r2
 800004c: 40010800 andmi r0, r1, r0, lsl #16

I'll admit it don't make a lot of sense to me ATM. Particularly those load stores. My own version to flash an LED isn't quite there yet either. I'm beginning to think it may actually take me more than 3 instructions to do it but we shall see.

ps. What does the "=" mean in your operands? I see it appends data to the binary but why?

It's also surprising you abandoned the ".thumb" directive. Was that intentional?
« Last Edit: September 07, 2014, 09:03:30 pm by paulie »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #68 on: September 07, 2014, 10:13:16 pm »
Good news. I've finally got that damn LED to flash. It didn't take 3 instructions as predicted. Only 2! This is great. Now to see if a character can be sent out via UART. I'm not going to worry about baud rate for now. Just get anything to squirt out then maybe adjust clock to get it right as a next step.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #69 on: September 08, 2014, 06:41:44 am »
Quote
Code: [Select]
08000008 <_start>:
 8000008: e59f0038 ldr r0, [pc, #56] ; 8000048 <delay+0xc>
 800000c: e5901000 ldr r1, [r0]
 8000010: e3811004 orr r1, r1, #4
 8000014: e5801000 str r1, [r0]
 8000018: e1a00000 nop ; (mov r0, r0)
That's interesting.  You're getting 32bit instructions.  Oh, I think I see.  I had removed the .thumb directive, because it seemed to be doing the same thing as the -mcpu=cortex-m3 option in my compile line, but you probably aren't using that option...

Quote
What does the "=" mean in your operands? I see it appends data to the binary but why?
The ARM doesn't have a "load from 32bit address" instruction, nor an instruction to load an arbitrary 32bit constant intro a register.   (presumably because those would make instructions 64bits long, screw up the pipeline, and stuff like that.)
Every load instruction has an index register, and a relatively small offset (<4096) from that index register.
So the usual way to access a peripheral register is to load its address into an index register, and then access it via the index register.
And the usual way to load a 32bit address into an index register is to stick that constant in memory "near" the code that needs it, and access it by indexing off of the PC register.  The "=constant" assembler structure  sets that up for you; plunks the constant in nearby code space and sets up a pc-indexed instruction to access it.

Interestingly (?) MIPS code on PIC32 has similar limitations on constants, but the compiler produces sequences like "move the high 16bits of the constant into the high 16bits of the register, OR the register with the low 16bits of of the constant."
« Last Edit: September 08, 2014, 06:47:48 am by westfw »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #70 on: September 08, 2014, 11:28:22 pm »
Thanks for that explanation. I was aware of the difficulty loading 32bit immediates but wasn't up to speed on '=' symbol so was using a rather crude method. Now my own LED program is much cleaner.

Regarding the .thumb issue the source directive does behave slightly different  than command line option.  NOP actually comes out NOP (bf00) with the latter but mov r8,r8 (46c0) with the former. Don't really matter I guess but interesting.

BTW to compensate for the missing .equiv in your .asmh file, in order to stop the undefined error message I added the following line to your version:

.equ RCC_APB2ENR,0x40021000

ps. It compiles ok now. I had some trouble failing to reset at first but it blinks fine. Congratulations, I was proud of myself for managing to turn on the LED but looks like you are the first person to ever actually continuous blink in assembly.
« Last Edit: September 08, 2014, 11:38:39 pm by paulie »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #71 on: September 09, 2014, 01:33:23 am »
Well, days ago, for a different ARM, different assembler: http://www.eevblog.com/forum/microcontrollers/stm32-ghetto-style/msg503594/#msg503594

I've decided that I REALLY dislike "@" as a comment character.

Here's the code with "homework" style comments:

Code: [Select]
/*
 * BLINK in ARM Assembler
 * For ST32F103c8t6, perhaps
 * Aug 2014, by Bill Westfield - released to Public Domain.
 */

.include "stm32f103c8.asmh"
.syntax unified
.thumb

/*
 * Options settable by the user.
 */
.equ STACKSIZE, 1024
.equ HEAPSIZE, 8192
.equ myport, GPIOA_BASE /* must be portA... */
.equ mybit, 6 /* arbitrary bit choice, for now. */

/*
 * The ARM needs at least two words at the start of the flash that
 * specify the initial stack pointer and the reset start address.
 */

        .globl  _Vectors
_Vectors: .word    SRAM_BASE+HEAPSIZE+STACKSIZE /* Top of Stack */
.word   _start + 1            /* Reset Handler (thumb!) */

.globl  _start
_start:
/*
 * In order to use the GPIO ports, you first have to enable
 * a clock to that port.  This is done through the "Reset and
 * Clock Control (RCC) structure, but there are random different
 * registers/bits depending on which bus has the peripheral.
 *
 *  C equivalient: myClkCtrlReg |= myClkEnaBit;
 */
ldr r0, =RCC_APB2ENR
ldr r1, [r0] /* old val */
orr r1, r1, #RCC_APB2ENR_IOPAEN /* enable PORTA clk */
str r1, [r0]

/*
 * Now set up the GPIO pin for output.  Each pin is controlled
 * by 4 bits in the CRL or CRH register (depending on bit)
 *
 *  C equivalient: mygpio.CRx = MYGPIOMODE<<(myBitPos);
 */
initf: mov r1, #((GPIO_MODE_OUT+GPIO_CNF_PP) << (mybit*4))  /* output bits */
ldr r0, =GPIOA_BASE /* GPIO_PORTF */
str r1, [r0, #GPIO_CRL_O]  /* set bit to output */

/*
 * Now loop around and toggle the GPIO pin.
 * While the port has atomic set/reset ports, I'm going to just
 * do a non-atom read and xor.
 *
 *  C equivalient: while (1) { mygpio.ODR ^= 1<<mybit ; }
 */
mov r2, #(1<<mybit)    /* put the bit mask in a register */
loop: ldr r1, [r0, #GPIO_ODR_O] /* read DATA reg */
eor r1, r2          /* complement bit */
str r1, [r0, #GPIO_ODR_O] /* write */

/*
 * Delay loop.  I pick a constant that's a power of two so that
 * a single instruction with a shifted 8bit constant will be used.
 *
 *  C equivalient: for (uint32_t i=4096*1024; i != 0; i--) {}
 */
mov r1, #(4*1024*1024) /* Delay count */
delay:   subs r1, #1 /* decrement */
  bne delay

b loop

.end
 

Offline timb

  • Super Contributor
  • ***
  • Posts: 2528
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: One Dollar One Minute ARM Development
« Reply #72 on: September 09, 2014, 02:08:37 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)

Uh, Tarball files are a very, very common way of delivering development tools on the Mac. Since OS X is running a delicious chewy *NIX core, the built-in Archive utility will de-compress them just fine straight through Finder.

This is not some GUI based development tool. You have to use it through the command line anyway, so why would you expect them to package it in a DMG?


Sent from my Smartphone
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #73 on: September 09, 2014, 09:32:31 am »
I've decided that I REALLY dislike "@" as a comment character.

I also dislike that queer '@' but the C convention '/*...*/' strikes me as a big pain in the ass too so it's C++ '//' for me. What's even stranger is the disassembler uses ';'. There are other issues that cause LST code to not compile. Not a good thing for GCC or any other assembler IMO.

Anyway we have a problem Houston. These routines blink fine when run from the bootloader but fail miserably on reset or power up. I've attached a file for your program called noblink.hex and one for one that doesn't misbehave in this way, blink.hex (PB3). WTF. It looks like it should work but we are missing something. Maybe hw faults so full blown vector table is required. That is one difference compared to the working one. Maybe the bootloader is failing to enter with reset defaults (BAD bootloader!). It's not register dependency lost on power down because simple reset acts the same. One of the Ebay blue boards is being used for these latest tests to minimize chance of hardware incompatibilities but same thing with the DIY. IDK.
« Last Edit: September 09, 2014, 09:45:30 am by paulie »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #74 on: September 09, 2014, 09:52:32 am »
Quote
we are missing something.
Probably some sort of necessary clock initialization.  The TI tiva i've been playing with has some reasonable defaults and just runs things slowly if you haven't done anything, but it wouldn't be unusual for there to be more...
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #75 on: September 09, 2014, 10:18:07 am »
Probably some sort of necessary clock initialization.

It's not obvious how that could happen. At reset PLLON is clr but HSION is set so should be running, maybe not maximum speed. I don't see how any application could run without a crystal if that's the case yet the example I posted does. What a mystery.

If somebody could post a small hex file for one of the ST C demos or some other popular blinky I could get to the bottom of this quickly. Unfortunately I'm not set up for that ATM.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #76 on: September 09, 2014, 11:27:39 am »
Quote
I could get to the bottom of this quickly.

This is why no body can afford to code in assembly if her/his time means something, anything.
================================
https://dannyelectronics.wordpress.com/
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #77 on: September 09, 2014, 11:52:48 am »
It's amazing how many don't get this. Just jump to the end of a thread and start making noise. I will repeat that the intent here is not to create a race of human centipede uber-coders. I can program in C and spend a lot of time doing that. The goal here is to develop a set of absolute MINIMUM tools for a common ARM device pretty much for the sake of doing just that. Understanding more about the machine and tools is an incidental but IMO beneficial side effect.

As insane as it sounds a buddy of mine actually builds quite fancy ships inside a wine bottle using tweezers and teriyaki sticks. No matter how often I try to explain that it would make much more sense to simply assemble one on the tabletop and put it inside a peanut butter jar he just won't listen. Some people!

If you want to contribute something constructive how about attaching one of those really small blinky images you brag about all the time. You know, for this chip. We know you have the tools.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #78 on: September 09, 2014, 12:06:40 pm »
I do love assembler, but on mips, arm or any other RISC processor I rather use C or C++.
They usually have enough memory and speed that really doesn't matter, but I do get the power of assembly and once you have a bunch of cool modules done you can link them to your C code :)
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #79 on: September 09, 2014, 12:08:00 pm »
lol.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #80 on: September 09, 2014, 12:27:45 pm »
lol.

I'm not really kidding, but for example for Arm processors that don't have native floating point or even integer division like the M0 assembly is the way to implement it.

So anything related to inner loops, assembly will give you an edge, the upper control stuff doesn't matter much since everything can run at 100 Hz now a days and a couple of microseconds is not going to make a difference at that level.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #81 on: September 09, 2014, 01:09:57 pm »
Saturating arithmetic also is a legit use of asm om arm as far as I'm concerned. Mostly as inline assembly used from C. But indeed, sometimes constructing a fast loop in asm can be fun too. Only to find out later that in some (but not all) cases the optimizer does a better job than you. :P
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #82 on: September 09, 2014, 01:30:15 pm »
Yes, it's hard for a human to compete with some of these compilers and GCC is pretty damn good for the money. I'd say that 99% of the assembler I've learned came from examining list files of C routines. The big problem is compiler overhead. For example my LED routine comes out a little over 100 times bigger when compiled instead of assembled. Of course the difference is much less with programs of significant complexity.
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 874
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #83 on: September 09, 2014, 01:31:42 pm »
The goal here is to develop a set of absolute MINIMUM tools for a common ARM device pretty much for the sake of doing just that. Understanding more about the machine and tools is an incidental but IMO beneficial side effect.

[...]

If you want to contribute something constructive how about attaching one of those really small blinky images you brag about all the time. You know, for this chip. We know you have the tools.
Well, "absolute MINIMUM" and "common ARM" are conflicting requirements. The minimum requirement puts you in the lair of the RCC/clock dragon, which blasts different fire for each OEM. If you were willing to leave the teriyaki sticks in the kitchen, you could do a nice minimum build over CMSIS, slaying the RCC beastie with a single call to SystemInit(). That would be in C, of course, but you have to choose: macho assembler warrior or stealthy C assassin?

To regain some nerd cred, you might consider re-writing the post-initialization blinky bits in GCC's inline assembler. That would be sufficiently awful to keep the pragmatists off your doorstep and entertain the eastern European whiz-kids.

I'd post a .hex, but all of mine have an RTOS in the middle.  >:D
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #84 on: September 09, 2014, 01:40:48 pm »
Well, "absolute MINIMUM" and "common ARM" are conflicting requirements.

I disagree. The device I've chosen is more popular than it's next competitor by a huge margin if listing statistics on places like Ebay, Aliexpress, and many other websites are an indication. And when you have attached a fully functional toolset to a forum like this instead of just links that argument would be more convincing.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #85 on: September 09, 2014, 01:43:54 pm »
RTOS. lol.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #86 on: September 09, 2014, 02:22:02 pm »
RTOS lol yes. I suffer from the same affliction. RTOS, C, C++, asm all rolled up in one project. Because ... why not?  :-//  You use whatever tool gets the job done.

Programming in asm every now and then is fun, but I'm definitely not going to write entire applications in it. ;)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #87 on: September 09, 2014, 02:44:39 pm »
Quote
Quote
    Probably some sort of necessary clock initialization.
It's not obvious how that could happen.
I was thinking something like "well, the CPU clock defaults to the 8MHz internal HSI, and you enabled the clock from the APB2 bus to the GPIO port, but you forgot to turn on the clock for the APB2 bus itself." (though it doesn't look like that should be necessary.)  Or perhaps I can't use GPIO_Speed_10MHz if the clock is only 8MHz.

Then there is the (horribly documented) APB2RSTR register...
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #88 on: September 09, 2014, 07:00:06 pm »
I put up a new version of the .asmh file.
It includes some macros STRUCTDEF/STRUCTEND and support infrastructure, to allow simple C structures to be relatively easily converted to assembler symbols.  So code that looks like:
Code: [Select]
/**
  * @brief CRC calculation unit
  */
STRUCTDEF CRC
  __IO uint32_t DR;
  __IO uint8_t  IDR;
  uint8_t   RESERVED0;
  uint16_t  RESERVED1;
  __IO uint32_t CR;
ENDSTRUCT
(which is easy to get from the C-style .h file using some editor keyboard macros) ends up producing assembler that defines CRC_DR=0, CRC_IDR=4, CRC_RESERVED0=5, CRC_RESERVED1=6, CRC_CR=8...

And then I added all the stm32f103 peripheral internal structure definitions.
(The CAN peripheral is incomplete.  A CAN peripheral apparently includes arrays of CAN_TxMailBox structures, and my macros aren't up to doing nested structures.)

This requires a bit of editing of the blink.S sketch I posted (remove the _O from the offset names of the manually-defined GPIO peripheral registers.)

(Needless to say, this has not been extensively debugged.)

I suggest adding "-mcpu=cortex-m3" to the assembler command  line, and you might want to consider "-asl=blink.lis" to generate a "significantly aware" listing file (which has advantages and disadvantages.  The concise output produced by objdump is ... concise.  The assembler listing ... isn't. (91 pages for blink.lis  Mostly the (largely useless) bitmask symbols, which could be omitted by using -al=blink.lis instead.)
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #89 on: September 09, 2014, 08:31:47 pm »
Quote
We know you have the tools.

I didn't want to deprive you of the hardly earned bragging rights of developing an almost-working blinky after a few days. That must be the longest one minute in history, :)

Yes, I have the tool.

But, I don't have the time to waste.
================================
https://dannyelectronics.wordpress.com/
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 4983
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #90 on: September 09, 2014, 08:33:48 pm »
Assembler only when C is not sufficient, for instance with large multiplications you can not transfer the carry with C  :(
The assembly routine is much faster. But there you can use inline assembly.
People who write everything in assembler are probably from the 80's where you had 256 byte ROM sizes, now with modern ARM controllers going >2MB ROM good luck, would love to see someones IP stack written in assembly  :-DD
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #91 on: September 09, 2014, 08:38:27 pm »
Quote
would love to see someones IP stack written in assembly

or a fft routine fully in assembly.

Writting assemblies has its place: when you are pushing the envelope of performance or resources (tons of money for example).

Most of us just cannot afford to write in assembly, in terms of skill, resources (time included), or necessity. C is much cheaper.
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #92 on: September 09, 2014, 08:58:37 pm »
Heh.   Implement the core arduino functions, in asm, designed to be called from asm...

 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #93 on: September 09, 2014, 09:35:58 pm »
Quote
would love to see someones IP stack written in assembly

or a fft routine fully in assembly.

Writting assemblies has its place: when you are pushing the envelope of performance or resources (tons of money for example).
Most of us just cannot afford to write in assembly, in terms of skill, resources (time included), or necessity. C is much cheaper.
There are very few places where an assembly programmer can create faster code than a C compiler nowadays. A C compiler can take caching, branche prediction, pipelining, etc into account. Besides that it is often much more efficient to choose a better algorithm (or come up with one) than trying to speed up a less efficient algorithm.
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 #94 on: September 09, 2014, 10:54:03 pm »
I agree. These GCC routines were developed over many years by some of the top assembly language coders in the world. I know the examples I've extracted from list files were impossible for me to improve in terms of speed or size. IIRC more than once on forums like AVRfreaks (where asm is also feared by many) challenges were proposed but few succeeded. I think the only fellow who did was that Russian guy who got banned by shamed and frustrated mods. Another example might be the Multiwii project where expert coders spent huge effort to speed up cycle time, including hundreds of posts dealing with assembly tweaks, with little or no actual benefit.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #95 on: September 09, 2014, 11:43:04 pm »
Prompted by a request for simple low cost intro to the 32bit world in this thread: ...

This thread went completely off from being 'simple' or 'intro'.
Drain the swamp.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #96 on: September 10, 2014, 12:29:37 am »
How did I know you were going to say that? Evidently "simple" is in the eye of the beholder. Last week I didn't just link but actually attached a 100% functional set of tools for creating ARM programs. This was the first time anything even close was done here or any other forum AFAIK. I also set up a script that involves hitting a key on your PC keyboard or clicking with a mouse. I don't think anything like that has ever been done before either. Also note that these scripts are so small and simple can fit into text files of a couple dozen bytes.

The "zapta challenge":

Just to reiterate:

ARM hardware $1 and change.

Ability to start coding and flash in about a minute after downloading tools. In fact the package chosen is so compact this most likely includes  download time too.

So I'm quite pleased and really do not require recognition or complements because it's obviously hard to say anything with those human centipede stitches in ones mouth.

BTW With some help from an offline hex (actually elf) contribution and oocd the mystery of why westfw code don't run on reset is solved. Unbelievable.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6004
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #97 on: September 10, 2014, 12:54:56 am »
How did I know you were going to say that?

Because it's true.

In the other thread you said that you will recover a simple ARM introduction that you presented in some ham club but this thread doesn't deliver.
Drain the swamp.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #98 on: September 10, 2014, 12:57:17 am »
How did I know you were going to say that?

Because it's true.

In the other thread you said that you will recover a simple ARM introduction that you presented in some ham club but this thread doesn't deliver.

How did I know you were going to say that? LOL
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #99 on: September 10, 2014, 01:33:52 am »
Girls, play nice and don't fight with each other.

Quote
actually attached a 100% functional set of tools for creating ARM programs.

If that's the case, why waste time on creating a half-functioning assembly code? Give people .axf and you are done.

If you want to see how others have done this, check out some of the stm8 software usb examples on the web.

Blinking an led on this board (or pretty much any other board, arm or not) is fairly easy, especially for a C expert like yourself. Why compete where your skills are none by writing in assembly?

If you cannot write a blinky in C, I posted a short piece in the ghetto thread that blinks an led on any STM32F10x chips. It would be a ride in the park for a seasoned C programmer like yourself to get it going on your hardware.

From where I sit, you haven't demonstrated the need, skills or resources to code in assembly.
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #100 on: September 10, 2014, 01:42:47 am »
Quote
would love to see someones IP stack written in assembly

http://pdp-10.trailing-edge.com/SRI_NIC_PERM_SRC_1_19910112/01/6-1-monitor/tcptcp.mac.html

(and several related files.)

(If you do read through this code, keep in mind that it is/was one of the very first TCP implementations!)
« Last Edit: September 10, 2014, 01:53:46 am by westfw »
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 4983
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #101 on: September 10, 2014, 03:55:52 am »
http://pdp-10.trailing-edge.com/SRI_NIC_PERM_SRC_1_19910112/01/6-1-monitor/tcptcp.mac.html (and several related files.)
(If you do read through this code, keep in mind that it is/was one of the very first TCP implementations!)
Thanks, and you have proven my point, this kind of code is totally unmaintainable or expandable (someone wants to add the TLS1.2 spec to it?)  ;)
But indeed in the 80s a lot of code was written in assembly, most of the consumerelectronics were written in assembly. My first steps into microcontrollers (8048) were in assembly, but that does not justify to keep on using it in the 21st century (unless it is for hobby like puzzles).
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #102 on: September 10, 2014, 03:59:17 am »
why waste time on creating a half-functioning assembly code?

I'm surprised so many keep missing the point but I don't mind repeating.

Because the intent was to provide a set of ARM tools that are basic enough to attach to a forum not just link and set up so even a beginner can download and test in less than a minute. That's what I claimed and that's what I did. This has never been done before, here or anywhere else.

If you want to see how others have done this, check out some of the stm8 software usb examples on the web.

Copying off the net is your game.  For my current purpose trailblazing has proven more productive. At least for this project. BTW I do have an STM8 Discovery and ran all the demos. However I lost interest quickly when it became apparent there were few advantages over other 8 bit devices like PIC or AVR and many drawbacks. Cost, performance, features. So I'll leave that scientific curiosity up to you too.

Blinking an led on this board (or pretty much any other board, arm or not) is fairly easy, especially for a C expert like yourself. Why compete where your skills are none by writing in assembly?

I'm certainly not an expert in C like you claim to be. As far as asm it don't look like you've ever seen let alone worked with a line of code. When you accomplish anything even close to what I've done come back and we'll talk.

Apparently you are an expert  on hardware tools too. Any more info on this?

There is also an approach that does not require the flash loader demonstrator - hyperterminal is all you need.

Any links or other details? No?

If you cannot write a blinky in C, I posted a short piece in the ghetto thread that blinks an led on any STM32F10x chips. It would be a ride in the park for a seasoned C programmer like yourself to get it going on your hardware.

Yes, I see you have just caught on to what is not only most common arm chip but really the best deal in that category too. But I requested a hex file not half baked C demos off the web. Anyway it's no longer needed. A hex (actually elf, even better) was provided by a generous offline contributor. It provided the missing link I needed to solve that mystery.

Anyway I don't think you ever had the courtesy to post a working hex file. Maybe with all the GUI layers you don't know how. Like with the arduino gang. ATM there is little inclination for me to get sucked into that toolchain whirlpool you call a development environment.

From where I sit, you haven't demonstrated the need, skills or resources to code in assembly.

Well it looks like I am possibly the first and only person to post a working version of ARM assembly blink program in this forum. OK, the program wasn't written by me but I got it working. Possibly westfw was able fix the include bugs and hasn't posted them yet. The latest version gets T32_OFFFSET_IMM something error with the basic CLI commands. It might be we are out of sync with command options again IDK. So attached is his previous asmh with a minor fix to suppress errors and working hex from his unmodified original source:
« Last Edit: September 10, 2014, 04:37:34 am by paulie »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #103 on: September 10, 2014, 05:33:01 am »
Quote
For my current purpose trailblazing has proven more productive.

Quote
Well it looks like I am possibly the first and only person to post a working version of ARM assembly blink program in this forum. OK, the program wasn't written by me but I got it working.

Wow!

you redefine sha@#$. OK, you redefined "traiblazing", ;0

It takes more than "audacity" to claim what you did.

As to your being the "only" one. Have you thought about why you are the "only" one? Running down the autobahn butt-naked will make you the only one too but most people would understand why the "only" one there isn't so desirable.

Do you?
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #104 on: September 10, 2014, 05:35:04 am »
Quote
this kind of code is totally unmaintainable or expandable

Bingo!

You hit it right on the head.

As hardware costs continue to decline and software costs continue to rise, the trade-off continues to shift towards more stylized software.
================================
https://dannyelectronics.wordpress.com/
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #105 on: September 10, 2014, 05:44:55 am »
you redefine sha@#$. OK, you redefined "traiblazing", ;0

I'm sure you can provide evidence to the contrary. SOMEBODY must have attached a functional set of ARM tools before. SOMEBODY must have provided a way for noobs to check them out without spending days or weeks or months. SOMEBODY must have posted a working binary assembled for ARM blinky before. No?

It takes more than "audacity" to claim what you did.

It takes ARROGANCE!

"I am great, yet I am humble."
-Shark
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #106 on: September 10, 2014, 07:31:00 am »
Quote
SOMEBODY must have posted a working binary assembled for ARM blinky before. No?

That's good. That means humanity has honor, knows right from wrong, smart from not-so-smart.

That means there is hope for all of humanity, minus the obvious one of course.

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

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #107 on: September 10, 2014, 07:33:16 am »
Quote
New .asmh file added in

why?

Just use the header files from CMSIS / libraries.
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #108 on: September 10, 2014, 08:21:42 am »
Quote
Just use the header files from CMSIS / libraries.
They don't support assembler. (for two reasons.  The first and most significant is that (in theory) while you could use the C preprocessor even when programming in asm, the CMSIS headers are full of constructs like
Code: [Select]
#define CRC                 ((CRC_TypeDef *) CRC_BASE) which the assembler is not going to recognize after substitution (nor do I see a way to add additional CPP or asm macros to simplify it enough to make a difference)
The second reason is that the preprocessor isn't included in the "reduced tool set" that we're trying to use (for better or worse.)

Part of the reason for the experiment are the frequent complaints I see of the form "I hear that Atmel Studio for ARM, scatters 3GB+ of crap all over my disk."  ("Yeah, TI's CCS does that too."  "MPLABX isn't much better."  etc.)  So here we a "usable" toolset in less than 6MB, that goes exactly where you put it.  That's 500x less space...
Sure, I'd prefer "Borland C for ARM", but efforts in that direction (pcc ?)  don't seem to be getting anywhere.

Arguably, for minimum trouble you should spend the $100 to get something like Imagecraft's "Non commercial" ARM compiler/IDE.  (~500MB)  The real truth is that there isn't anyone doing this "for real" to whom $100 and a hour or two of download/install time is a real barrier.  It *is* a sort of academic exercise...
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #109 on: September 10, 2014, 08:28:16 am »
Quote
which the assembler is not going to recognize after substitution

Use the base address.

Code: [Select]
  ldr R0, =RCC_BASE + RCC_AHBNER_OFFSET @load ahbner address into R0

would work.

You have to define RCC_AHBNER_OFFSET (which the header file specifies), obviously.
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #110 on: September 10, 2014, 09:35:06 am »
Quote
  ldr R0, =RCC_BASE
Assuming that it would get that far, this would expand to
Code: [Select]
ldr r0,=((((uint32_t)0x40000000)+0x20000)+0x1000)which generates errors
Code: [Select]
foo1.S: Assembler messages:
foo1.S:6: Error: missing ')'
foo1.S:6: Error: missing ')'
foo1.S:6: Error: missing ')'
foo1.S:6: Error: garbage following instruction -- `ldr r0,=((((uint32_t)0x40000000)+0x20000)+0x1000)'
You get similar errors for "=(((()0x40000000)+0x20000)+0x1000)"...

But of course it doesn't get anywhere near that far, since the .h file also has plenty of "typedef" statements that the assembler doesn't understand at all either:
Code: [Select]
stm32f10x.h:1266: Error: bad instruction `typedef struct'
stm32f10x.h:1267: Error: junk at end of line, first unrecognized character is `{'
stm32f10x.h:1268: Error: bad instruction `__io uint32_t CR'
stm32f10x.h:1269: Error: bad instruction `__io uint32_t CFR'
stm32f10x.h:1270: Error: bad instruction `__io uint32_t SR'
stm32f10x.h:1271: Error: junk at end of line, first unrecognized character is `}'
If I understand things correctly, this is the format/methodology that CMSIS requests/requires of the include files.
And the explicit casts on all constants are recommended/required by other standards, right?  (MISRA?)
So the CMSIS header files are pretty much defined to be an assembler-unfriendly format...

I think the only architectures I've seen .f files set up to be used by both assembler and C is the Atmel AVR.
(Microchip 8bit PIC has separate .h and .inc files, IIRC.)

Quote
You have to define RCC_AHBNER_OFFSET (which the header file specifies), obviously.
I did find some sites that have instructions for generating gnu assembler xxx_OFFSET macros from C structure definitions.  ( http://docs.blackfin.uclinux.org/doku.php?id=toolchain:gas:structs )  Just create a special C file that references all the structure offsets that you're interested in, run it through the compiler till you get generated asm, process that with awk, and bob's your uncle.  I think I prefer my technique (though the blackfin technique would have handled those structs containing arrays of other structs that mine didn't.)
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #111 on: September 10, 2014, 06:27:07 pm »
My methodology involves pulling out datasheets and snipping register tables. Then, using macro/replace ability of my editor (emacs variant), convert entries to .equ or #define depending on language. Rarely do I bother with bit definitions. Those and other less common details may end up as immediates with comments or equ/define in the source file if used more than once or twice. Rarely do i bother to download the official include packages.

This has worked out well in the 8 bit world. Lately not so much for ARM due to somewhat nasty docs. Most of my efforts are not that complex. Certainly not on a par with things like mw or ardupilot, but a few did make it to market. The "sometimes less is more" philosophy has served me well. I spend more time actually writing programs and less struggling with tools.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #112 on: September 10, 2014, 08:59:51 pm »
Quote
You get similar errors for "=(((()0x40000000)+0x20000)+0x1000)"...

You are right.

I ended up with the following arrangements:

Code: [Select]
@set gpio2
ldr R0, =GPIOC_BASE @read gpioc base into r0
ldr R1, [R0, #GPIO_ODR_OFF] @read gpioc odr
ldr R2, =GPIO_ODR_2 @read odr2
orrs R2, R2, R1 @r1|r2->r2
str R2, [R0, #GPIO_ODR_OFF] @send it back to odr

GPIOC_BASE is separately defined as:

Code: [Select]
.equ PERIPH_BASE, 0x40000000 @peripheral's base address
.equ APBPERIPH_BASE, PERIPH_BASE
.equ AHBPERIPH_BASE, (PERIPH_BASE + 0x00020000)

.equ GPIOC_BASE, (AHB2PERIPH_BASE + 0x00000800)

Retained the names from the .h file.


Quote
But of course it doesn't get anywhere near that far, since the .h file also has plenty of "typedef" statements that the assembler doesn't understand at all

They compiled flawlessly for me:

Code: [Select]
#include <stm32f0xx.h>
#include "stm32f0xx_rcc.h"
#include "stm32f0xx_gpio.h"

.syntax unified

@system defines
@RCC offsets
.equ PERIPH_BASE, 0x40000000 @peripheral's base address
.equ APBPERIPH_BASE, PERIPH_BASE
.equ AHBPERIPH_BASE, (PERIPH_BASE + 0x00020000)
.equ AHB2PERIPH_BASE, (PERIPH_BASE + 0x08000000)
.equ RCC_BASE, (AHBPERIPH_BASE + 0x00001000) @rcc's base address
...

Except that they do nothing yet, until I figure out how to use the defines.
================================
https://dannyelectronics.wordpress.com/
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #113 on: September 11, 2014, 05:31:28 am »
Except that they do nothing yet, until I figure out how to use the defines.

If that's the case, why waste time on creating a half-functioning assembly code? Give people .axf and you are done.

From where I sit, you haven't demonstrated the need, skills or resources to code in assembly
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #114 on: September 11, 2014, 07:52:51 am »
 ;D Kinda had that one coming.

Just popping in to say, this is a neat exercise.  Not practical, just entertaining and educational.  Carry on.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #115 on: September 11, 2014, 08:29:59 am »
LOL I hope Danny gets it.

Thanks. "Not practical, just entertaining and educational" was the plan from day one. Maybe people are beginning to get that now. I know I've come a long way last few days thanks to guys like westfw, nctnico, and, I hate to admit, Danny too (don't tell him I said that).
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #116 on: September 11, 2014, 09:21:28 am »
Your secret's safe with me. ;)

BTW... I, for one, do and did get it.  I've often been surprised how strongly people oppose doing things the hard way (or whatever) at least once, to better understand how it works.  You'd think, in groups of engineers and hobbyists, taking the scenic route wouldn't be in the least bit controversial.  But often it is.  *shrug*  I have never understood that.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #117 on: September 11, 2014, 09:28:24 am »
Quote
I ended up with
why?  I mean, OF COURSE you can create your own .equivs for whatever constants you want, but that's tedious and error-prone compared to have an algorithmic translations of the .h file (which is what I've done to create the .asmh)
I don't think we're specifically restricting ourselves to the "most primitive environment possible" (though it may feel that way.)  We're trying to provide the best possible environment within a constraint of size/time.  Adding a 60k (compressed) file of assembler-style definitions is within the constraint.

Quote
compiled flawlessly for me
I don't see how that's possible.  You're not even defining the specific chip, which should bump you immediately into:
Code: [Select]
#if !defined (STM32F030) && !defined (STM32F031) && !defined (STM32F051) && !defined (STM32F072) && !defined (STM32F042)
 #error "Please select first the target STM32F0xx device used in your application (in stm32f0xx.h file)"
#endif

(Hmm.  Are using using "arm-none-eabi-as" as the assembler?  That doesn't invoke theC preprocessor, and includes a quirk of commenting such that lines beginning with # are essentially ignored, so #include doesn't actually include anything...  To "assemble" a file that uses C macros, you usually use the xxx-gcc command (the gcc .exe being essentially a front end that invokes xxx-cpp, cc1, xxx-as, and xxx-ld and perhaps others depending on command line switches and file extensions.)
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #118 on: September 11, 2014, 10:30:32 am »
We followed a different process. I followed a typical C project process to the end. Then delete main.c, and instead include main.S.

I will also choose CMSIS as part of the set-up.

I eventually wrote a small piece of code (h2inc) that generated stm32f0xx.inc from stm32f0xx.h to retain the base addresses. That header file is then included in the main.S to provide base addresses for the code.

Using CMSIS has the advantage of having access to SystemInit() and SystemCoreClockUpdate(), as having your stack / heap set up by the start-up file automatically.

My code looks like this:

Code: [Select]
.include "stm32f0xx.inc"
.syntax unified
.thumb

@system defines
@RCC offsets
.equ RCC_AHBENR_OFF, 0x14 @ahbner offset

@gpio offsets
.equ GPIO_MODER_OFF, 0x00 @gpio moder offset
.equ GPIO_OTYPER_OFF, 0x04 @output type
.equ GPIO_ODR_OFF, 0x14 @output data register
.equ GPIO_BSRR_OFF, 0x18 @output bit set / reset register
.equ GPIO_BRR_OFF, 0x28 @output bit reset register

@global defines
.equ LED_PORT, GPIOC_BASE @led on gpioc
.equ LED_A, (1<<1) @led anode on pin1
.equ LED_C, (1<<2) @led cathode on pin2

@global variables


.global main @so it gets called from CMSIS
.type main, %function
@.text @declare it in the code section

main:
@user main starts here

init:
@initialize the chip
@enable clock to gpioc
ldr R0, =RCC_BASE @read rcc base address into r0
ldr R1, [R0, #RCC_AHBENR_OFF] @read ahbner register into R1
ldr R2, =RCC_AHBENR_GPIOCEN
orrs R2, R2, R1 @set GPIOCEN bit, R2 | R1 -> R2
str R2, [R0, #RCC_AHBENR_OFF] @update ahbner register

The bulk of the code compiled is actually in the .inc file - almost 400k and 5000+ lines - many of it is actually masked off.

Unfortunately, there is no way to calculate the offsets so you have to manually set them up.
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #119 on: September 11, 2014, 12:44:04 pm »
So are we now at "why use a .asmh file generated from ST .h files using your procedure when you could have used a .inc file generated from ST .h files using MY procedure"?  I'll accept that as a "victory."  The resulting files seem be be about the same size, and everything (also about the same size as st's original .h files.  I wish they didn't spend so much time/space defining PERIPHNAME_REGNAME_0 (through PERIPHNAME_REGNAME_31) and similar for each bit of every register where the bits don't have a particularly nameable function...
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #120 on: September 11, 2014, 01:22:21 pm »
It would be interesting to see if using a file generated for the device in this thread actually compiles unlike the asmh files which do not.

ps. And if the program using it actually runs.
« Last Edit: September 11, 2014, 01:43:59 pm by paulie »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #121 on: September 11, 2014, 02:47:52 pm »
I should start including by example program in with the .asmh file.  I did mention that the _O symbols were replaced...
It turns out that error messages like
Code: [Select]
blink.S:61: Error: cannot represent T32_OFFSET_IMM relocation in this object file formatis "I am a lousy assembler"-speak for "the symbolic name you used in this instruction is undefined." (actually, it seems to have automatically made it "external", and then discovered that the linker doesn't support the required sort of math on the value.  Or something like that.)

Here's the most recent .asmh file.  Now includes NVIC and SysTick peripherals (from ST's core_cm3.h), and deleted some of the pointless bit value definitions.

 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #122 on: September 11, 2014, 04:54:03 pm »
It compiles OK but unfortunately don't blink. I haven't deciphered your code yet. Did you change the bit or something? On same hardware the original one blinks when used with the older asmh that I hacked.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #123 on: September 11, 2014, 05:46:24 pm »
I didn't think I had changed anything.  :-(

My board is supposed to arrive tomorrow.  What did you say you were using for upload?  (JTAG, Serial, USB?)

Hmm.  It looks like when I added the offsets to the .asmh file, I forgot that my older version had created absolute values for some things with the same name.   So the code currently has
Code: [Select]
ldr r0, =RCC_APB2ENRand that (now) needs to be
Code: [Select]
ldr r0, =RCC_BASE+RCC_APB2ENR
I see a disadvantage to having dropped the _O syntax for offsets :-(
(although the peripheral register names are now ALL offsets, and always need to add some _BASE value via indexing or addition.)
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #124 on: September 11, 2014, 06:33:37 pm »
Just like the version of yours that works it was assembled with first page utilities and downloaded using that ST serial flash program attached there. I peeked and see the bit has not changed so maybe something to do with the new include file. I really can't make heads or tails of actual addresses anymore what with all the offsets, bases, shifts etc.. Same tools as with my own super simple LED program from last week with just plain ol' hex numbers. No includes or even defines. Maybe a comment or two if you're lucky.

I'm sure things will move quickly when your board shows up. No hardware is a huge handicap IMO.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #125 on: September 13, 2014, 09:07:01 am »
Spreadsheet of board/chip pinout, for the $7 board variants we've been talking about:

https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZdGR6cVprUnkwTV9CMUNybV9VMjF5a0E&usp=sharing

(No hardware yet :-( )
« Last Edit: September 13, 2014, 10:46:34 am by westfw »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #126 on: September 13, 2014, 10:49:03 pm »
Somebody offline requested more wiring information so I've added a photo of the bottom of the board in the second post. Also one showing a run/boot switch and reset button. Something like this is essential if you are interested in testing or modifying the simple LEDA9 program that I attached there last week or the hacked version of westfw files from a couple pages back.

Speaking of which, westfw, did your board come in? Everything working as expected? If so maybe put up a known good include/blinky pair for those who might be interested in more serious asm development than my crude demo.
 

Offline neslekkim

  • Super Contributor
  • ***
  • Posts: 1301
  • Country: no
Re: One Dollar One Minute ARM Development
« Reply #127 on: September 14, 2014, 04:10:46 am »
Spreadsheet of board/chip pinout, for the $7 board variants we've been talking about:

https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZdGR6cVprUnkwTV9CMUNybV9VMjF5a0E&usp=sharing

(No hardware yet :-( )

is pin 47-48 marked wrong on the board?
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #128 on: September 14, 2014, 06:55:10 am »
Yes, good call. That certainly looks like a typo because, glancing at my breakout board, pin 47 must be ground not 3v or there would have been sparks on the dozens built so far. I'm sure westfw will be along to fix that. I'm also hoping what may be bugs in the latest blinky or include file can be updated. That would be very useful for anybody venturing beyond my dumb demo.

ps. Pin 48 with VCC looks correct. On my breakout board GND pins are on the outside and VCC pins on the inside which makes it very easy to build and check. The power pins are shorted inside the chip so double checking with a meter will show instantly if theres a miswire. Interestingly even though bypass caps seem to be optional these duplicate pins must all be wired together or the chip don't work.
« Last Edit: September 14, 2014, 07:06:41 am by paulie »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #129 on: September 14, 2014, 07:39:09 am »
Quote
is pin 47-48 marked wrong on the board?
The "board" pin numbers do not match up with the chip pin numbers, and are just arbitrary.  Probably not "right", because I'm not aware of a standard for quad in-line "packages." (that's one reason I added the annotated photo.)

I see I have two "28" and no "29"; oops.

Is there a schematic or more detailed description of the board-level circuit somewhere?  Most of it is self-explanatory, but paulie said  "boot1 and boot0 markings are swapped on many of them", for example...

PS: My board that was supposed to arrive on thursday actually arrive today (Sat);  I have fixed the stm32flash utility from google code to compile on my Mac (have I mentioned that so far I've been using a Mac for all of this?), so I'll soon see if it works...

« Last Edit: September 14, 2014, 07:41:34 am by westfw »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #130 on: September 14, 2014, 09:32:59 pm »
Quote
I'll soon see if it works...
I'm not having too much luck...
The bootloader should ALWAYS run when boot01 is 1/0, and it should run forever waiting for the proper serial comm, right?  My mac doesn't seem to be talking to the board at all, either via the stm32flash utility I found, or through a serial terminal emulator :-(  My PC seems to be able to talk to the board via the ST flash load demo "sometimes", and perhaps "most of the time" via putty. (note: same serial HW on both PC and Mac, and it seems to work fine in loopback or talking to another serial adapter.)  Sigh.
 

Offline neslekkim

  • Super Contributor
  • ***
  • Posts: 1301
  • Country: no
Re: One Dollar One Minute ARM Development
« Reply #131 on: September 14, 2014, 10:34:29 pm »
Quote
is pin 47-48 marked wrong on the board?
The "board" pin numbers do not match up with the chip pin numbers, and are just arbitrary.  Probably not "right", because I'm not aware of a standard for quad in-line "packages." (that's one reason I added the annotated photo.)
The reason I asked, is that the board number in the spreadsheet, and the picture below, differs, on the picture it clearly states GND, and the spreadsheet says 3v3, so I wondered if the board are wrong, or the spreadsheet (there are known to be some boards comming from china that have errors.. )
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #132 on: September 14, 2014, 11:10:57 pm »
The bootloader should ALWAYS run when boot01 is 1/0, and it should run forever waiting for the proper serial comm, right?

Right. As of yesterday I've built nearly 100 of the DIY boards for myself and friends and although there's only one Ebay blue board in my collection I've poked at half dozen others. No flakyness so far. These things either worked or they didn't. When they didn't it always turned out to be something wrong with my wiring or procedures.

The only intermittent boot failures were long time ago with PIC and AVR and traced to bogus USB/serial. There are "issues" regarding hardware and drivers. I'm quite an expert on those (among other things. LOL) so suggest putting up a photo of yours, either from the original ad or snap one. Where did it come from? The $1 Ebay dealies with DTR are very reliable.

ps. All PC  for me, Win and Linux but no Mac.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #133 on: September 15, 2014, 01:02:18 am »
Somebody else on this end just had some problems so here's a couple more hints. As mentioned in the first post you MUST reset the chip before each download and make sure the "run user" box is checked. Some hints on the ST flash demo: set timeout for 1s. If it's not recognized by then somethings wrong. Also use 256kbaud which for some reason is more than 3x faster than 115k (6s vs 20s).
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #134 on: September 15, 2014, 08:17:23 am »
Quote
There are "issues" regarding hardware and drivers.
Bingo!  Things work much better using my trusty FTDI cable.  I was trying to use on of those CA-42 phone cables (with a (probably counterfeit) Prolific chip) that were the state-of-the-art cheap usb-serial solution a couple of years ago.  I suspect that the chip/driver combination doesn't like the somewhat unusual 8bits plus Even parity configuration.

Update: Woo hoo!  I have blinking!

(huh.  One tends to look down on those arduino female connectors where everyone just plugs in wires and components.  But it's a PITA to stick female connectors on the end of LEDs (for example) so that they're easy to attach to these boards with male pins...)
« Last Edit: September 15, 2014, 12:13:41 pm by westfw »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #135 on: September 15, 2014, 03:43:49 pm »
Code: [Select]
08000036 <delay>:
 8000036:       3901            subs    r1, #1
 8000038:       f47f affd       bne.w   8000036 <delay>
 800003c:       f7ff bff5       b.w     800002a <loop>
I can't figure out why it's generating "long" branches.  My Keil assembler example puts each of those branches into a single 16bit instruction.   I can't find any relevant switches, directives, or instruction variants that look  like they'd change the behavior :-(
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 4983
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #136 on: September 15, 2014, 06:14:23 pm »
Code: [Select]
08000036 <delay>:
 8000036:       3901            subs    r1, #1
 8000038:       f47f affd       bne.w   8000036 <delay>
 800003c:       f7ff bff5       b.w     800002a <loop>
I can't figure out why it's generating "long" branches.  My Keil assembler example puts each of those branches into a single 16bit instruction.   I can't find any relevant switches, directives, or instruction variants that look  like they'd change the behavior :-(
Did you set the target device correctly?
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #137 on: September 15, 2014, 07:08:46 pm »
I have -mcpu=cortex-m3;  shouldn't that be enough?

 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #138 on: September 15, 2014, 07:50:07 pm »
Quote
Woo hoo!  I have blinking!

Two weeks later, one of two "experienced programmers" eventually succeeded in blinking an led. The other one is still trying.

Phew!

Talk about steep learning curves, :)


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

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #139 on: September 15, 2014, 08:38:39 pm »
Talk about steep learning curves, :)
Well, since the stated mission objective basically is the learning curve I'd say mission accomplished. The learning curve has been measured succesfully!

Not entirely sure about that "one minute" part though. At least it isn't "one man" anymore, thanks to westfw joining the fray. The "one dollar" probably still holds, not counting time obviously.

And as added benefit, it results in a confirmation of my personal bias. That being: "asm only on ARM? Nope not worth the hassle". Another thing that came out of it IMO, is that even to get a meaningful asm only development environment, you cannot escape using other tools to get there. That being you have to parse C include files to get useable asm defines and such. And you can do the parsing either by generating some C files, compile it, and process the output. Or do some perl/python/sed/awk/whatever scripting to get the job done. Not that I personally have any problem with having to parse C stuff in order to get to the asm only step, but it does take away the "purist asm" award.

Anyways, it will be interesting to see what the minimalist setup binary size is compared to the C equivalent.
And after that it will be interesting to see what the development time is for a moderate size application compared to C. Because spending a lot of time ONCE to get a known to work setup with really small binary size, I totally dig that. You spend your time once, and then you reuse your awesomely small setup in all your following projects. It's the time spent on the average application after that which is the thing...

Or maybe make an optimized minimal setup, and then you hand off control to the rest of the app written in C.

Anyways, keep it up! It makes for interesting reading.  :-+
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 4983
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #140 on: September 15, 2014, 09:00:40 pm »
I have -mcpu=cortex-m3;  shouldn't that be enough?
yeah should be enough I thought you might have selected generic ARM.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #141 on: September 16, 2014, 12:36:28 am »
To be fair, most of the two weeks in my case was spent waiting for HW to arrive.
I could've gone to radioshack and picked up an arduino and spent the time (more than one minute) it takes to download the Arduino SW.  Or for that matter, it would have been a very slow internet connection not to have been able to download "more than just the assembler" in the time I spent soldering (even though I got a pre-assembled board, and only soldered up several adapter cables.  (one of which didn't work.))
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #142 on: September 16, 2014, 01:07:45 am »
I can't figure out why it's generating "long" branches. 

 I can't find any relevant switches, directives, or instruction variants that look  like they'd change the behavior :-(

Adding ".n" pseudo-op will force short addressing as shown in the first two examples below.

Also note that, as mentioned early in this thread, using "=cortex-m3" CL option does not result in the same binary as ".thumb" directive. I discovered this right after you introduced me to the latter. Various combinations of CL options and source directives can produce quite varied output. Functionally similar but... Compare binary generated for NOP and address length of branch.

Code: [Select]
arm-none-eabi-as -mcpu=cortex-m3 -o t.o t.s
with:

.thumb
.syntax unified
 nop
start:
b.n start

begat:

08000000 <start-0x2>:
 8000000: bf00      nop
08000002 <start>:
 8000002: e7fe      b.n 8000002 <start>

Code: [Select]
arm-none-eabi-as -mcpu=cortex-m3 -o t.o t.s
with:

.thumb
.syntax unified
 nop
start:
b start

begat:

08000000 <start-0x2>:
 8000000: bf00      nop
08000002 <start>:
 8000002: f7ff bffe b.w 8000002 <start>

Code: [Select]
arm-none-eabi-as -o t.o t.s
with:

.thumb
.syntax unified
 nop
start:
b start

begat:

08000000 <start-0x2>:
 8000000: 46c0      nop ; (mov r8, r8)
08000002 <start>:
 8000002: f7ff bffe b.w 8000002 <start>

Code: [Select]
arm-none-eabi-as -mcpu=cortex-m3 -o t.o t.s
with:

.thumb
.syntax unified
 nop
start:
b .

begat:

08000000 <start-0x2>:
 8000000: bf00      nop
08000002 <start>:
 8000002: e7fe      b.n 8000002 <start>

Code: [Select]
arm-none-eabi-as -o t.o t.s
with:

.thumb
.syntax unified
 nop
start:
b .

begat:

08000000 <start-0x2>:
 8000000: 46c0      nop ; (mov r8, r8)
08000002 <start>:
 8000002: e7fe      b.n 8000002 <start>

One (one with open mind anyway) can learn a lot from little experiments like this. Another thing I can't understand, or forgive in this case, is the objdump LST output being incompatible with the assembler. For example our beloved ';' comment characters which are sprinkled throughout. Kinda like the ST bootloader failing to restore reset defaults before running user.

Software engineers, can't live with 'em, can't shoot 'em. Well you could but then what would internet hotshots argue about?
« Last Edit: September 16, 2014, 02:10:14 am by paulie »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #143 on: September 16, 2014, 11:02:35 am »
Initializing the clock for 72MHz, controlled by the external crystal:
Code: [Select]

/*
 * Initialize the clock to our max speed (72MHz), assuming an external 8MHz crystal.
 * This also involves configuring the flash for wait states, and dividing the APB1
 * (low speed peripheral bus) clock.
 */
ClockInit:
/*
* Set the flash for 2 wait states - the max needed at 72MHz.
* (do this FIRST!)
*/
ldr r0, =FLASH_R_BASE /* Flash control register */
ldr r1, [r0, #FLASH_ACR]
orr r1, #FLASH_ACR_LATENCY_2 /* Set for two wait states */
str r1, [r0, #FLASH_ACR]

/*
* Enable the oscillator for the external crystal, and wait
* for it to finish starting up.
*/
ldr r0, =RCC_BASE /* Clock control registers*/
ldr r1, [r0, #RCC_CR] /* get control reg contents */
orr r1, #RCC_CR_HSEON /* Turn on crystal oscillator */
str r1, [r0, #RCC_CR]
clklp: ldr r1, [r0, #RCC_CR]
tst r1, #RCC_CR_HSERDY /* wait for clock ready */
beq.n clklp


/*
* Configure and enable the PLL,then start it and wait for lock.
*/
ldr r1, [r0, #RCC_CFGR] /* Get clock config register */
orr r1, #RCC_CFGR_PLLMULL9 + RCC_CFGR_PLLSRC_HSE /* Multiply osc by 9 */
orr r1, #RCC_CFGR_PPRE1_DIV2 /* But make sure APB1 is < 36MHz */
str r1, [r0, #RCC_CFGR]
ldr r1, [r0, #RCC_CR] /* get control reg contents */
orr r1, #RCC_CR_PLLON /* Turn on PLL */
str r1, [r0, #RCC_CR] /* store */
plllp: ldr r1, [r0, #RCC_CR]
tst r1, #RCC_CR_PLLRDY /* wait for clock ready */
beq.n plllp

/*
* Select the PLL output as our system clock
*/
ldr r1, [r0, #RCC_CFGR]
orr r1, #RCC_CFGR_SW_PLL /* Select PLL */
str r1, [r0, #RCC_CFGR]

bx lr  /* Return */

What a pain in the neck - a perfect example of the sort of low-level grunt-work on uninteresting peripherals that an embedded programmer would rather not waste time figuring out.   (The standard peripheral library code that does this looks like it would expand to "really big."  It's got abstractions piled on top of abstractions, properly sets/clears the state of nearly every bit (even if you "know" the startup state) (and pretty much one bit/field at a time.))

(I keep or-ing bits into my registers, and forgetting to store them back to the peripheral. HLL habits.)

(Is it working?  I dunno.  It blinks faster than it used to.  It doesn't look 9x faster, though.  I'm not sure how those wait states end up affecting the timing of the simple blink loop.  Next step; SysTick.)

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #144 on: September 16, 2014, 11:43:51 am »
observation: The .asmh isn't as much use as it might be, because most of the C examples use the peripheral library calls instead of the stm32f10x.h level structures and register values.  So you can't simply translate most of the existing C examples into asm; you have to either dig through the peripheral library source, or go all the way back to the datasheet.

Got out the scope, increased the frequency, and did some measuring.   With the clock configuration code in, the pin is only toggling at about 4x the rate with the internal 8MHz clock... ???

 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #145 on: September 16, 2014, 08:39:08 pm »
Your program compiled and ran just as expected on my blue board. At least once the LED was moved to the right pin. That new MYBIT did throw me for a loop (haha... you got me!). Commenting the 2 calls also caused it to run slower pretty much the same as you described. I tried to make it compatible with the hardware on page one by changing MYBIT to 9 and CRL to CRH but no go. Looks like I'll have to do a little disassembly to see what I missed.

I gotta say that code is just about the best tutorial on ARM assembly published on the net so far. I would love to put that up at the beginning of the thread to help the unwashed masses. First I need to get that bit moved and it would be nice to figure out why the clock is not running exactly as expected. In any case thanks for that and hopefully you won't give up.

I wish my UART experiments were going as well. Looks like divisor issues. I was hoping to avoid it but maybe it will be necessary to get involved with that clock stuff after all.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #146 on: September 16, 2014, 09:00:15 pm »
Quote
Is it working?  I dunno.

Follow the datasheet; If that's too difficult, follow the library; If that is even too difficult, follow the SetSysClock() in the system_xxx.c -> that's the closest example.

Quote
the unwashed masses.

With your demonstrated skills and experience, it is probably unjustified to call people that way. Be humble.

Quote
Looks like divisor issues.

Probably more than that.

Quote
most of the C examples use the peripheral library calls instead of the stm32f10x.h level structures and register values.

most of them rely on the base address and register struct established in stm32f10x.h. The register values are generally replaced by enums in the peripheral library and the bit values are generally not used.
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #147 on: September 17, 2014, 03:46:00 am »
Quote
Quote
Is it working?  I dunno.
Follow the datasheet
Oh, my code  does something.  What I mean is that I am having trouble figuring out how fast my delay loop should run if I increase the clock rate from 32 Mhz to 72Mhz, when that also means adding two wait-states to the flash controller, AND the "prefetch buffer" is turned on, AND I have the ARM pipeline to contend with as well.  (technically, you're not supposed to run 32MHz, 0-wait states.  But that did seem to work.  Unlike 72MHz @ 0 WS, which I also ended up trying accidentally.)  So I don't know for sure whether the processor is actually running at 72MHz and is slowed down by WS and code structure, or whether I have some mistake that is causing it to run a a different clock rate than I expect.  (Different PLL multipliers are just changes of a constant, and I'm definitely multiplying by SOMETHING, so it's difficult to imagine what would cause a different clock rate than expected...

I should probably import the max-rate pin toggle code from that other thread and do some real measurements...

Quote
follow the library
Oh, I am.  More or less.  The library code is "deep."  Pretty much for every assembly language statement I have in my clock init function, the library function (setSysClockTo72()) has one or more function calls, frequently with parameters that don't match exactly with the stm32f10x.h symbols.  I hope a lot of that gets inlined and optimized away because things are constants.   (Could you post disassembled setSysClockTo72() code, since you have a C/plib environment handy?)  They also explicitly set a lot of bits/fields to the default poweron values, while my code is assuming that it's starting with poweron values.  (it looks like the plib would allow you do do things like:
Code: [Select]
setSysClockTo72();  // run fast.
 toggletest();
 setSysClockToHSE();  // basic crystal rate
 toggletest();
 setSysClockTo48();  // intermediate speed
 toggletest();

I have to say that what the peripheral library documentation may lack in clarity, it makes up for with excellent cross-reference links to the actual source code.  Browsing through the library with a CHM browser is ... pretty nice.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #148 on: September 17, 2014, 05:10:48 am »
If I were you, I would increase the speed to 24Mhz, WS0. Measure the blinking frequency; and then 24Mhz, WS1, measure the blinking frequency again. I can tell from my own experience, flash ws has a bigger impact on the execution speed.

If you look at the SystemInit() or the library, you will see lots of looping around for the oscillators / PLL to be ready. That's one area where a mistake could have been made.

You can check if you look at the RCC registers, particularly the pre/after multipliers to be sure that you are running at 72Mhz.

SetSystenClock() is in the system_xxxx.c file.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #149 on: September 17, 2014, 05:12:10 am »
Quote
it makes up for with excellent cross-reference links to the actual source code.

The use of doxygen helps. But more important than that is the availability of "go to definition" of your IDE. It is a life saver.
================================
https://dannyelectronics.wordpress.com/
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #150 on: September 17, 2014, 06:41:51 am »
Quote
the availability of "go to definition" of your IDE. It is a life saver.
In this case, I'm particularly appreciating having that function available OUTSIDE any IDE.  (That probably means having a separate html (.chm ?) file for each C source module. which tweaks my frugality sense.  But it's still nice...)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #151 on: September 17, 2014, 07:55:43 pm »
Here's the timing table.  I shortened the loop to
Code: [Select]
loop: ldr r1, [r0, #GPIO_ODR] /* read DATA reg */
eor r1, r2          /* complement bit */
str r1, [r0, #GPIO_ODR] /* write */
b.n loop
(NOT the shortest possible loop, BTW.)   And I implemented some symbolic indirection to make it easier to change the values (code attached.)  The no-wait-state code looks like it's taking about 9 clocks for the 4-instruction loop, which is not as good as I thought it would be (although I wouldn't find 6 surprising - 1 extra for the 32bit instruction and one extra for the branch.)  Maybe I've left something out?

Impressive Overclocking success!

Code: [Select]
          ------------(MHz)--------
PLLMULT F(cpu)  F(0WS)  F(1WS)  F(2WS)
  -       8     0.444   0.400   0.364
  3      24     1.330   1.200   1.091
  4      32     1.779
  5      40     2.225*          1.818
  6      48     2.669*
  7      56     3.115*
  8      64     fail    3.200*  2.91
  9      72             3.600*  3.27
 10      80**           4.000*
 11      88**           4.400*
 12      96**           4.800*
 13     104**           5.200*  4.73
 14     112**           5.600*
 15     120**           6.000*
 16     128**           6.400*  5.8

   * exceeds documented memory speed
  ** exceeds documented cpu max freq

Update: using a sequence of stores, I can get "about" 2MHz pin toggle running at 8MHz/0WS, or 18MHz at 72MHz/2WS (that's still slower than I expected (~2cycles per store), but the flash prefetch unit seems to be helping.  The 72MHz version is running 9x the 8MHz version, despite increasing the waitstates to be "legal."):
Code: [Select]
ldr r1,  [r0, #GPIO_ODR] /* read DATA reg */
eor r1, r2, #(1<<mybit)
loop:
str r1, [r0, #GPIO_ODR] /* 1 write */
str r2, [r0, #GPIO_ODR] /* write */
str r1, [r0, #GPIO_ODR] /* 2 write */
str r2, [r0, #GPIO_ODR] /* write */
str r1, [r0, #GPIO_ODR] /* 3 write */
str r2, [r0, #GPIO_ODR] /* write */

« Last Edit: September 17, 2014, 08:54:34 pm by westfw »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #152 on: September 17, 2014, 11:00:13 pm »
Good news that the expected 9x is now demonstrated. I've verified the scope timing on this end too. There are too many differences from the previous version for me to easily follow so I wonder if you can explain what  changed. Did you alter the clk/pll code or was it due to the new fast loop? What actually caused the 4x speedup to become 9x?
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #153 on: September 18, 2014, 12:27:01 am »
Two weeks later, one of two "experienced programmers" eventually succeeded in blinking an led. The other one is still trying.
Phew! Talk about steep learning curves, :)

All I can suggest Danny is don't give up. More than a few rank beginners managed to get the LED demo posted on first page couple weeks back working and it only took them a minute or two so there is hope. I posted not only source but binary ready to flash in case it's tools that are causing you trouble.

BTW did I forget to mention that the entire development set is attached not just linked so should be quite easy to manage.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #154 on: September 18, 2014, 01:10:10 pm »
Quote
I wonder if you can explain what  changed.
The big change was these additions at the top to options:
Code: [Select]
.equ DODELAY, 0 /* if 0, just toggle at max loop speed. */
/* if 1, blink at human-like speeds */
.equ WAITSTATES, FLASH_ACR_LATENCY_1
.equ PLLMULT, RCC_CFGR_PLLMULL9
@ .equ PLLMULT, 0 /* If 0, don't use the PLL */
/*  Note that xxx PLLMULL2 is 0, so this structure */
/*  doesn't support x2 clock configurations */
then the ClockInit code uses the new symbols (PLLMULT, WAITSTATES) instead of the symbols direct from the .asmh files.
And there is some conditional assembly to leave out the PLL code if the multiplier is zero, and leave out the delay loop when DODELAY is 0.

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #155 on: September 18, 2014, 01:29:29 pm »
Oh yeah:
Quote
What actually caused the 4x speedup to become 9x?
The actual speedup going from 8MHz 0WS code to 72MHz 2WS code is 3.3/.444, or about 7x...
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #156 on: September 18, 2014, 04:30:06 pm »
PSoC version, although I payed too much for the board (breakable schmartboard that I still have the other half).

So $3 for the board, $1 for the chip and after I put it together I did the blinky in less than 1 minute without counting wiring it up to my pioneer.

Programming was as simple as getting the blink demo, changing the led pin and that's it.

The code it generated
Code: [Select]
#include <device.h>

int main()
{
    /* Start the Clock and PWM components. Clock can be started automatically
    after reset by enabling “Start on Reset” in the Clocks tab of
    Blinking LED.cydwr. We are doing this manually for instructive purpose. */
    Clock_Start();
    PWM_Start();

    for(;;)
    {

    }
}

Schematic:


Board:


Operating voltage 1.8V to 5.5V unregulated (using internal regulator, therefore the bypass caps). You can short VDDD and VCCD if you supply a regulated (1.8 ±5%)V without the need of the bypass caps).
Edit: but if you use the bypass caps, you get the regulated output out off VCCD as shown in the image is pretty close to 1.8 and well within the operating parameters.

To program it, I'm using my Pioneer dev kit ($25) with a modified KitProg that allows me to program external chips instead of the one within the Pioneer.


Edit: plus this has programmable Analog and Digital logic.

« Last Edit: September 18, 2014, 06:35:06 pm by miguelvp »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #157 on: September 18, 2014, 05:06:33 pm »
Code: [Select]
/* [PSOC Blink main loop] */
    for(;;)
    {

    }

Um.  I see no blinking.  Is it setting up the PWM with a 50% duty cycle and human-scale period?
How big is the binary?  For PSoC, you have to include the bits that define the hardware in your executable, don't you?  It's not something you can program on the chip separately and have all of the (rather limited) code space left for software?
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #158 on: September 18, 2014, 05:31:57 pm »
The purpose of the OP is One Dollar One Minute ARM Development

Sure I can forsake the PWM but that might take me a couple of weeks to program instead of under one minute ;)

Nah, takes less than a minute as well:

Code: [Select]
#include <project.h>

int main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
    for(;;)
    {
        /* Place your application code here. */
        Pin_Blue_Write(~Pin_Blue_Read());
        CyDelay(500);
    }
}

As for resources, yeah it does uses 1K of flash but that's not the thread subject.


Steps to do this where:

Create New Project
Empty PSoC4 template
Add digital output pin and name it Pin_Blue
Select GPIO p0[3]
Add two lines of code in the for loop
Compile and program.
« Last Edit: September 18, 2014, 05:35:35 pm by miguelvp »
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #159 on: September 18, 2014, 06:29:28 pm »
BTW I can do my own component with my own support code (even in assembly if so inclined) instead of using the very accommodating built in modules.
Also I can define my own Schematic/Verilog to use the Digital/Analog hardware abstraction on top of the support software.

Oh, and you can just write to the address 0x40040000u and set or clear the bit for the port you want (in my case bit 3) for P0[3].
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #160 on: September 18, 2014, 07:40:44 pm »
Thanks for the update.  The original "one minute" referred to tool download/install time, not "time to write your first program."  (obviously, the painful asm programs are getting written rather slowly.)  As a 365+MB download, I don't think PSoC designer meets that specification.  In fact, the download manager they want you to install first is already bigger than the complete toolset we're using here...

I guess PSoC tools have more than the usual lock-in, since you need it to configure the hardware blocks as well compile the C code.  I guess that in theory you can create the hardware configuration with the Cypress tools, and import them into some other compiler?
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #161 on: September 18, 2014, 09:49:29 pm »
BTW I can do my own component with my own support code (even in assembly if so inclined)

I'd be impressed if you actually managed that. Even if we did relax the download requirement. Assembly blinky for Cypress chip that can be demonstrated in less than a minute? Quite a challenge.

I ordered one of the $4 boards and a few $1 (soon to be $3) chips but even with help from The Creator I doubt this will ever be as easy as the GNU procedure published here. I'm not sure a couple op amps are worth the extra expense and development complexity. But like I said, it would be very impressive if you managed to strip down the tools to the point a noob can get going in anything close a short time frame.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #162 on: September 19, 2014, 12:38:46 am »
How about 32MB? and 3rd party support (at least uVision) plus lattice and xilinx toolchain for the fpga part of things I believe but I haven't read the full paper. (you need to be registered to download it)

http://www.cypress.com/?rID=38050

As for building your own component they have some tutorials somewhere and they are simple to make with their toolchain.

Edit:
the lattice and xilinx support is to program the chip as well.

After all is just another Cortex M0 chip (M3 for the PSoC 5LP)
« Last Edit: September 19, 2014, 01:39:41 am by miguelvp »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: One Dollar One Minute ARM Development
« Reply #163 on: September 19, 2014, 01:42:22 am »
Quote
(at least uVision

From a library perspective, it is non-existent - RTE doesn't currently cover those chips and unlikely ever. Cypress doesn't provide a library to cover those chips either.

You have to read the datasheet and two trms to get it going.

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

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #164 on: September 19, 2014, 02:55:06 am »
Or maybe it's simpler than that:

Quote
Using the CY8C42xx Example Project
1. Install Keil µVision MDK-ARM Standard Version 4.54 (or later).
2. Copy the CY8C42xx.FLM file to C:\Keil\ARM\Flash. This file will be selected during µVision
startup.
3. Connect ULINKPro to the USB port and then connect it to the target board. In the example, the
10-pin ARM connector is used, although only five pins (VCC, GND, XRES, SCLK, and DATA) are
required
...
11 more steps all defined in that document.

Edit:
BTW the default file location will be here (part of the 32MB download):
C:\Program Files (x86)\Cypress\Programmer\3rd_Party_Configuration_Files\CY8C42xx\Prog_Algorithm
And the template project here:
C:\Program Files (x86)\Cypress\Programmer\3rd_Party_Configuration_Files\CY8C42xx\Template_Project

These are the devices included in the 3rd party configuration folder, the Documentation has the same 3rd party pdf you can download individually in that programmer link earlier on.




« Last Edit: September 19, 2014, 03:53:44 am by miguelvp »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #165 on: September 19, 2014, 06:05:31 am »
I might suggest a challenge that is more about being able to simply create a program and flash it than trying to make asm look like C. Recall the program on page one here has no includes or even equates yet does compile and flash the LED.

Anyway I just pulled out my recently arrived 049-4xxx board and couple chips to take the new improved PSOC out for a spin. It's been a few years since my disappointing attempt with the $50 "hockey puck" programmer and $8 chips so the hope was things have improved. $4 is better than $50 and $1 ($3+ by month end) better than $8 but still some disappointments:

NO BOOTLOADER. This is a huge drawback IMO. Serial upload is what made STM32 chips so cheap and easy. "Free" as dannyf calls it. I'm guessing you have to blow another $30-$50 for Pioneer or Miniprog3. Not great at 10x the cost of STM. You can probably buy a few STM ICE setups for that too.

I find out now the chip on the 049-42xx card is not one of the $1 (soon to be $3) dealies. In fact it's very hard to determine just what chip is actually on there. Lots of mentions for their USB/serial device but not for the target in ads and docs. They seem to have actually erased the numbers off the top. WTF. It took a while but finally figured it out. Not too hard to locate the menu entry in Creator but far from minimum having to depend on that and generally annoying.

To download Creator you must register with their exclusive club which involves providing email and personal info. I do not need spam to double like last time so back on the "museum of interesting chips" shelf for now.

If there's anyway around these issues it might be somewhat more attractive and competitive with other options in the ARM world. However because of flashing hardware difficulties don't  look like it's possible for guys like me who just want to poke a stick at new chips without spending more than couple bucks. You know, like we can with  8051, AVR, STM etc..
« Last Edit: September 19, 2014, 06:34:13 am by paulie »
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #166 on: September 19, 2014, 06:54:12 am »
The ROM bootloader is pretty cool.  NXP has that, too.  I'm building a practical device - slash dev board right now with eight LPC812s, and one master LPC4078 on it.  I can take them all directly out of the tube and solder onto the board, upload the 4078 code via the serial interface that I needed anyway, and have it flash the 812s via its dedicated link to each of them.  Makes future firmware updates pretty easy too.  The 4078 will always have the latest image for the 812s, and can itself be loaded via IAP or, if totally bricked, from the UART again.  Only time I ever really need JTAG is for debugging. :-+
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #167 on: September 19, 2014, 07:41:19 am »
but still some disappointments:

NO BOOTLOADER. This is a huge drawback IMO. Serial upload is what made STM32 chips so cheap and easy. "Free" as dannyf calls it. I'm guessing you have to blow another $30-$50 for Pioneer or Miniprog3. Not great at 10x the cost of STM. You can probably buy a few STM ICE setups for that too.
The 049-41xx and 049-42xx both have bootloaders, they are programmed using the USB-Serial that only can be done in a presence of a bootloader. If you succeed in programming it without including the bootloader then it's pretty much bricked and you'll need a Pioneer or Miniprog to unbrick it and load a bootloader on it.


I find out now the chip on the 049-42xx card is not one of the $1 (soon to be $3) dealies. In fact it's very hard to determine just what chip is actually on there. Lots of mentions for their USB/serial device but not for the target in ads and docs. They seem to have actually erased the numbers off the top. WTF. It took a while but finally figured it out. Not too hard to locate the menu entry in Creator but far from minimum having to depend on that and generally annoying.
It's exactly the same chip, the PSoC 4 on the protoboard and the pioneer is the same CY8C4245AXI-483 of course you have the datasheets, schematics and BOMs available to double check but it's better to assume things. Also it's an angle thing but it's not erased but very faint on the protoboard.

To download Creator you must register with their exclusive club which involves providing email and personal info. I do not need spam to double like last time so back on the "museum of interesting chips" shelf for now.

That sounds just silly in many ways, I haven't receive a single spam from cypress


If there's anyway around these issues it might be somewhat more attractive and competitive with other options in the ARM world. However because of flashing hardware difficulties don't  look like it's possible for guys like me who just want to poke a stick at new chips without spending more than couple bucks. You know, like we can with  8051, AVR, STM etc..

Nah, just stick with what you have then

BTW I did download Keil V 4.74 and was going to set it up as in that paper, but the cypress chips were already installed.
Edit: link of Cypress supported ARM devices
http://www.keil.com/dd/chips/cypress/arm.htm

Oh and Creator can export full projects to Eclipse, uVision and IAR Embedded Workbench for ARM. But I think you are better off by leaving it in your "museum of interesting chips" shelf forever. Obviously is not for you.

Edit: Also need to add that the programmer that allows the 3rd party toolchains if you don't download the "download manager" it still have a direct link to get the 42MB installation file, so it's not required.
And lastly (well for now) C666 has mentioned many times that Cypress will price match even at low quantities with competitor chips, so even when they go up to $2.50 you might be able to get a better deal with some back and forth from their sales dept, but I have no experience with that so it's just word of mouth.
« Last Edit: September 19, 2014, 10:39:30 am by miguelvp »
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #168 on: September 19, 2014, 10:16:17 am »
32MB?  That's for the IDE?  Pretty good actually.  IAR EW noticed I had 2GB free on my laptop's SSD and decided to take it all.  There was a white-knuckle countdown as I waited to see which would get to 100% first:  The installation progress bar, or the disk utilization bargraph.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #169 on: September 19, 2014, 10:35:13 am »
No, that's for the programmer with 3rd party toolchain support, you can't develop with just that.

Still, it's just a plain Cortex M0 and can be programmed with 5 wires (VDD, GND, SWDCLK, SWDIO & RESET_n)
The programmer I use is just a PSoC5LP and that's because the 5LP has USB support so it's easier to connect to the PC.

Also they support Boundary-Scan Description Language (BSDL) programming and Serial Vector Format (SVF).

I think just using gcc and converting it to the right format will do the trick, but I'm not about to do all that since I rather use the toolchain supplied.

I'm going to give Kiel a try to see how small an executable I can make (in C), actually I'll just use the default template that they provide:

Code: [Select]
int WriteIO (unsigned int addr, unsigned int data)
{
unsigned int *address = (unsigned int*)addr;
*address = (unsigned int)data;
return (0);
}

int ReadIO (unsigned int addr, unsigned int *data)
{
unsigned int *address = (unsigned int*)addr;
*data = *address;
return (0);
}

//----------------------------------------------------------------------------------
// Custom functions
//----------------------------------------------------------------------------------

void Delay(int ms)
{
int i , j;

for(i = 0; i < ms; i++) {
for(j = 0; j < 3333; j++); //Delay = 1ms, mesured by scope for CY8C41xx (CPU = 48MHz)
}
}

void LED_Write(char value)
{     
WriteIO(0x40040000, value); //GPIO2.GPIO2_PRT.DR
}

//----------------------------------------------------------------------------------
// main() function
//----------------------------------------------------------------------------------
int main (void)
{
char leds = 0x01;     //Initial state of LEDs: P0[0] - On

WriteIO(0x40040008, 0x06); //Set Strong Drive Mode for P0[0] in GPIO2.GPIO2_PRT.PC register

for (;;)
{
LED_Write(leds); //Invert LED state on P[0] in GPIO2.GPIO2_PRT.DR register
Delay(500);
leds ^= 0x01;   
  }
}
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #170 on: September 19, 2014, 11:53:41 am »
So I used that code with uVision and this is the build log:
Code: [Select]
µVision Build Log

Project:

D:\Keil\ARM\Examples\Template_Project\Template_Project.uvproj
Project File Date:  12/14/2013

Output:

Build target 'Template_Project'
creating preprocessor file for main.c...
compiling main.c...
assembling startup_CM0.s...
linking...
Program Size: Code=212 RO-data=208 RW-data=0 ZI-data=512 
FromELF: creating hex file...
After Build - User command #1: .\Hex_Converter\HexConverter.exe .\\Hex_Converter\\Configuration.ini
".\Hex\Template_Project_uVision.axf" - 0 Error(s), 0 Warning(s).

Then since I don't have one of these programmers:


I took the generated cypress.hex file and use the PSoC programmer. My modified KitProg showed up and I was able to program the board blinking on p0[0]



But if I had one of those devices listed above I could just program and debug it using Keil uVision.

Maybe I would need to investigate on the external command line programmer but then I wouldn't be able to debug.

The thing is that the configurable modules are really code, there is no magic behind it at all, so the module designer just helps automate the process but just code can access all the features as far as I can tell.

Note I didn't use the Cypress toolchain at all, just the programmer because I didn't have one compatible with Keil

Edit: I forgot I had to change the device ID from 04_C6_11_93 to 04_A6_11_93 to match the SSOP
« Last Edit: September 19, 2014, 12:42:12 pm by miguelvp »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #171 on: September 19, 2014, 03:13:57 pm »
Quote
Empty PSoC4 template
Add digital output pin and name it Pin_Blue
Select GPIO p0[3]
How do you do that last part (selecting the external pin to go with the logic?)?  I can't find it :-(
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #172 on: September 19, 2014, 03:24:23 pm »
The schematic is file TopDesign.cysch that's where you put the pin and rename it.
The pins are on file projectname.cydwr under the pins tab

As in pictured here, i named my project blink1.

 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #173 on: September 19, 2014, 04:02:48 pm »
So I left a minor thing off, and of course it does remember my last chip so you can change the device you want to target. So here are the steps with pictures:

Edit: This requires a MiniProg3 (or a Pioneer Kit with a custom KitProg installed).
A Pioneer kit will work as well but only programming the built in PSoC 4 (CY8C4245AXI-483)

1) Create New Project
   File->New->Project

2) Select Empty PSoC4 Design and name project Blink (Click Ok)


3) Add digital output pin


(optional: if you need to change the chip right click on the project and do "Device Selector" and select your device)

4) Right click on pin, select Configure and name it Pin_Blue (Also Turn Hardware Connection off, and click OK)


5) Select GPIO p0[3]


6) Add two lines of code in the for loop

Code: [Select]
        Pin_Blue_Write(~Pin_Blue_Read());
        CyDelay(500);

7) Compile and program.



« Last Edit: September 20, 2014, 01:59:02 am by miguelvp »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #174 on: September 19, 2014, 04:29:50 pm »
Remember the pinout spreadsheet?

Quote
is pin 47-48 marked wrong on the board?
Yep; that was wrong.  Fixed now, and somewhat updated/reformatted.
Most importantly, now shows which pins are 5V tolerant.

https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZdGR6cVprUnkwTV9CMUNybV9VMjF5a0E&usp=sharing
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #175 on: September 20, 2014, 04:16:37 am »
AFAIK there are at least 3 slightly different versions of that from Ebay so those board pin numbers may not apply to all of them. In at least one case the power and ground were moved so there could be trouble. IMO better to refer to either signal names or chip pin numbers when pinout matters.

Another advantage of the DIY board besides cost and size is the label numbers match chip numbers. Too bad there's no room for signal names but then it would be almost as big as the blue board. A lot of us cut off the JTAG socket because it really serves no purpose.

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #176 on: September 20, 2014, 11:55:28 am »
do ANY of them have documentation?  I mean, what is the P2 jumper SUPPOSED to be for?
As a board, I find it pretty sucky; it makes me even more curious where it came from.
(Doesn't plug into a protoboard, can't be mounted on a "motherboard", has jumpers where it should have switches, mislabeled here and there...   Grr.)
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #177 on: September 21, 2014, 02:44:17 am »
LOL. All these Chinese clone-of-a-clone-of-a-clone boards have a back story just like USBasp, promini, serial dongles, etc.. In this case it started out as the ST reference design soon copied and produced by high end maker LCsoft. They were not $7 a pop back then. When second tier copycats like Seeedstudio, Betemcu, and the rest saw how quickly this rose to the top of the ARM dev board stack they jumped on the band wagon. Over the next couple years noname makers started cranking them out like cookies and the price plummeted. No more 50 bucks to play with ARM.

As far as docs there's quite a lot but unfortunately, unlike latest craze WiFi/serial modules, yet to be translated from Chinese. To complicate things variations from those from countries like India, who like to add "personal touch", resulted in many different schematic variations. Not all of them correctly labeled or documented. So here we are. Considering S&H quite a bargain unless you are not afraid to pick up a soldering iron which is an even better deal.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #178 on: September 21, 2014, 07:28:29 am »
To answer your question about the jumper, it connects USB pu r13 to USBP to enable enumeration. Notice that without this installed the PC pretty much ignores this interface. Since none of the open source STlink clone projects like Versaloon ever panned out USB serves no purpose on this board. Just annoying error messages with J2 installed.

Recall that on page one I suggested removing this jumper completely otherwise it's almost impossible to press the reset button.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #179 on: September 21, 2014, 05:51:18 pm »
I had removed the jumper to make the reset button easier to press (as you suggested), but I had installed a wire (as someone somewhere else suggested...)

Are there any communities that talk about programming the STM32 chips without the ST Peripheral Library?  I've been trying to get the USART working (in asm), without much luck.  The thread through the plib is hopelessly obscured compared to what I have in mind, so it's not very useful.  I've got:
Code: [Select]
UARTInit:
/*
 * Uart1 is on Port A9/A10
 * First Turn on clock for port A, including Alternate Functions, and UART
 * rcc->apb2enr = iopaen|afioen|usart1en ;
 */
bx lr
ldr r0, =RCC_BASE
ldr r1, [r0, #RCC_APB2ENR] /* old val */
orr r1, #RCC_APB2ENR_IOPAEN|RCC_APB2ENR_AFIOEN /* enable PORTA, AltFunc clk */
str r1, [r0, #RCC_APB2ENR]
orr r1, #RCC_APB2ENR_USART1EN
str r1, [r0, #RCC_APB2ENR]
ldr r1, [r0, #RCC_APB2RSTR]
orr r1,r2, #RCC_APB2RSTR_USART1RST
bic r1, #RCC_APB2RSTR_USART1RST
str r2, [r0, #RCC_APB2RSTR] /* Reset the UART */
nop
nop
str r1, [r0, #RCC_APB2RSTR] /* Un-reset */
nop
nop

/*
 * Set the pins appropriately (A9 as alt function output, A10 default to input)
 */
ldr r0, =GPIOA_BASE /* GPIO_PORTA */
ldr r1, [r0, #GPIO_CRH]
bic r1, ( (0xF << ((9-8)*4)) | (0xF << ((10-8)*4)) )
orr r1, #((GPIO_MODE_OUT50MHz+GPIO_CNF_AFPP) << ((9-8)*4))  /* output bit */
orr r1, #((GPIO_MODE_IN+GPIO_CNF_FLOAT) << ((10-8)*4))  /* input bit */
str r1, [r0, #GPIO_CRH]  /* set io bit modes */
/*
 * Set up the USART itself
 */
ldr r0, =USART1_BASE
ldr r1, =F_CPU/115200
str.w r1, [r0, #USART_BRR]
mov r1, #USART_CR1_TE+USART_CR1_RE  /* Enable TX and RX */
str.w r1, [r0, #USART_CR1]
orr r1, #USART_CR1_UE     /* Enable USART as a whole */
str.w r1, [r0, #USART_CR1]
/* CR2 and CR2 are OK at their default values */
mov r1, #'I' /* Initial test character */
str.w r1, [r0, #USART_DR]
bx lr

And let me take this opportunity to flame some more at the ST people.  Their explanation of the fractional baud rate divisor is ... awful - like it was written by someone who doesn't understand math.  And the library follows suit, doing weird math like:
Code: [Select]
   integerdivider = ((25 * apbclock) / (4 * (USART_InitStruct->USART_BaudRate)));   
   tmpreg = (integerdivider / 100) << 4;
   /* Determine the fractional part */
   fractionaldivider = integerdivider - (100 * (tmpreg >> 4));
   /* Implement the fractional part in the register */
   tmpreg |= ((((fractionaldivider * 16) + 50) / 100)) & ((uint8_t)0x0F);
   /* Write to USART BRR */
   USARTx->BRR = (uint16_t)tmpreg;
Whereas I claim (and have tested, on a desktop) that you can just do:
Code: [Select]
USARTx->BRR = apbclock/baudrate;Because they say that divisor = CLK/(16*Baud), and then convert the integer and fraction parts to nybbles in the BRR separately, but since the fraction needs to be in 16ths anyway, CLK/Baud already puts the same bits in the correct place.   Grr.
Maybe I should take the opportunity to complain about deriving the current clock rate from the internal state of the chip (but ultimately based on properly defining the crystal clock rate) instead of just #defining it, but I guess that makes SOME sense, what with the possibility of changing clock rates/etc for possible power saving reasons...

(In general, the pieces of the peripheral library that I've looked at SEEM like they were carefully written to be inline functions off in a .h file somewhere, which would cause a lot of the ickier looking code to optimize away and end up pretty reasonable.  And then maybe some higher-level manager came along and said "We can't have C code in .h files!  It's against the xyz standard policy!  Move it all into separately compilable library modules immediately!"   Sigh.)

 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #180 on: September 21, 2014, 11:02:40 pm »
Actually I have to agree that .h files are no place for C code. IMO that's asking for trouble and I don't mean just portability difficulties. But keep in mind that this is from someone who is an asm but not C expert. At least not on the level of you or Super Contributor (and ubiquitous, LOL) dannyf.

I finally did get the UART working and agree ST docs and libraries were not great help here. My divisor problems were solved with scope and dropping the baud rate down, WAY down. At some point I'll improve things by incorporating your PLL init code. Speaking of which I modified a couple lines in your PLL blinky to work on the DIY board and put it up on page one. Thanks for that. IMO the best learning tool for STM32 asm posted on the net so far.

Next step... three words: Aye... Dee... See!
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 3804
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #181 on: September 22, 2014, 01:03:01 am »
Actually I have to agree that .h files are no place for C code.

The only alternative is to make up some new extension for shared inline functions ... and that's just going to piss off 99% of C coders who have to work with your code. Shared inline functions go into .h, it's standard practice.

Maybe with LTO we will able to finally stop using inlining, depends on how they handle inline assembly.
« Last Edit: September 22, 2014, 01:04:44 am by Marco »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #182 on: September 22, 2014, 04:47:29 am »
Yes, it was not smart for me to include all include files in that comment.  More proper would be to say generally the initialization files and a lot depends on the compiler/assembler. The ideal situation would be ability use the same .h for C and asm but most families use different directives to define symbols so separate files are needed anyway. In that case it don't matter if there's code in there or not. Otherwise if you must put code in there make it assembler so it will be accepted by both the assembler and compiler. One of the nice things about GCC is open source and the ability to recognize directives by asm and C.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #183 on: September 22, 2014, 07:25:51 am »
Quote
I finally did get the UART working
Could you post that code?  I've about run out of ideas to try...

The details of the "management decision" aren't entirely relevant (and in retrospect, it might have been more like "The 'inline' keyword isn't standard C; we can't use that or the library won't be compilable with every conceivable C compiler that might exist."  (I keep seeing "inline" touted as a feature that was added by C++ (and as "one advantage C++ has over plain C is the "inline" capability"), even though I've been using it in standard C for decades...)

It's just ... there's a style of writing C code where you really COUNT on having the compiler optimize away a lot of your code, as an alternative to macros:
Code: [Select]
static const debugbits = 0;

  if (debugbits & DEBUG_PRINTCHARS) {
    // blah blah
  }
will normally compile to nothing just as well as
Code: [Select]
#if DEBUG_PRINTCHARS
   // blah blah
#endif
but not if put debugbits in a separate file and access it as "external" or a function parameter.  The Peripheral Lib code that I've looked through sort-of looks like it is written in that style, and then crippled.   I'll see if I can extract an example...
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #184 on: September 22, 2014, 03:47:31 pm »
Arrrgghhh!  I'm an idiot...
Code: [Select]
UARTInit:
/*
 * Uart1 is on Port A9/A10
 * First Turn on clock for port A, including Alternate Functions, and UART
 * rcc->apb2enr = iopaen|afioen|usart1en ;
 */
bx lr
ldr r0, =RCC_BASE
ldr r1, [r0, #RCC_APB2ENR] /* old val */
orr r1, #RCC_APB2ENR_IOPAEN|RCC_APB2ENR_AFIOEN /* enable PORTA, AltFunc clk */

You see that "bx lr" instruction right at the beginning of UARTInit?  (Neither did I.)  That's a "return" instruction; I added it early in my development as a way to test the syntactic correctness of the code (would it assemble) without actually running the code.  And I forgot to take it out, as I tweaked and fiddled with the rest of the init code (none of which ever executed, of course.

The UART works much better when you actually execute the initialization code!  (It showed up pretty quick when I went to the trouble to figure out how to import the .hex file into the debugger/simulator of one of the other development environments...)

Sigh.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #185 on: September 22, 2014, 05:34:27 pm »
Here's working "Hello world" code.
In addition to the UART, it includes use of push/pop, .asciz, .align, and gcc local labels.
It was SUPPOSED to demonstrate a clever way of passing arguments to subroutines, on systems that conveniently leave the return address in a register.  But because of the way Thumb return address work (lsb is 1 to indicate "thumb mode", even though there is no other possibility, and the code has needs to be aligned on even boundries, it turns out to be sorta gross :-(

 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #186 on: September 22, 2014, 11:38:30 pm »
Whew... That was close. For a minute there it looked like I would have to actually post my version. It would have been a huge embarrassment. Lots of 0xsumpinsumpin and not much RCC_whatever. No calls ATM either. So very nice contribution Bill.

It's not obvious but there are half dozen non-forum members hanging on every word here. Maybe suckers for punishment, maybe individuals with too much time on their hands, maybe just curious minds. In any case this is definitely fun and as an incidental side effect getting a hint what makes these things tick,
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #187 on: September 23, 2014, 12:22:02 pm »
Hmmmm... Two times more clicks on the bottles than the assembly file. I wonder if the universe is trying to tell me something.

Well, I put up a version on page one for posterity. It was only necessary to comment out the macro include line to get it to compile without errors. Thanks again for one of the best ARM assembly tutorials on the internet.

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #188 on: September 23, 2014, 06:38:33 pm »
Sorry about leaving the extra include in there; I had deleted the code that uses it.

FWIW, I've added a first attempt at ARM support to my "Structured Assembly" macros for the gnu assembler, which are here:
https://github.com/WestfW/structured_gas  In case you want to do things like
Code: [Select]
NESTIFTEST:             
        cmp r0, 12
        _if e
          mov r0, #5
          cmp r1, #13
          _if cs
            eor r2, r2
          _else
            add r2, r2
          _endif
          mov r4, #123
        _endif
       
        adds r0, r4
        _if eq
           add  r2,#1
        _else
           add  r2,#2
        _endif
It hasn't been heavily tested yet, the new comment character and asm-only environment caused some problems, and I found some bugs in the older code in the process of getting it working, so use with care if you use it at all (there doesn't seem to have been much interest in it, in general. :-(   Only crazy people use assembler any more, and they don't use the gnu assembler.)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #189 on: September 23, 2014, 07:57:26 pm »
Quote
I'll see if I can extract an example [of how the peripheral library looks like it was designed to be inlined.]
Here we go.  I wrote a tiny little program to initialize the USART using the ST peripheral library:
Code: [Select]
static USART_InitTypeDef myuartconfig = {
    115200, // Baudrate
    USART_WordLength_8b, // Wordlength
    USART_StopBits_2, // StopBits
    USART_Parity_No, // Parity
    USART_Mode_Rx + USART_Mode_Tx, // Mode
    USART_HardwareFlowControl_None // HW Flow
};

int main()
{
    USART_DeInit(USART1);
    USART_Init(USART1, &myuartconfig);
    while (1)
;
}
Doing NOTHING other than arranging for USART_DeInit and USART_Init to be included in source form and declared to be inline, code size was reduced by about 300 bytes!
Code: [Select]
/usr/local/armgcc/bin/arm-none-eabi-gcc -I . -DSTM32F10X_MD=1 -include assert.h -ffunction-sections -fdata-sections -O3 -g -Wl,--gc-sections main.c stm32f10x_rcc.c stm32f10x_usart.c

 /usr/local/armgcc/bin/arm-none-eabi-size a.out
   text    data     bss     dec     hex filename
   2816    1120      28    3964     f7c a.out


 /usr/local/armgcc/bin/arm-none-eabi-gcc -I . -DINCC=1 -DSTM32F10X_MD=1 -include assert.h  -finline-functions-called-once -ffunction-sections -fdata-sections -O3 -g -Wl,--gc-sections main.c

 /usr/local/armgcc/bin/arm-none-eabi-size a.out
   text    data     bss     dec     hex filename
   2512    1120      28    3660     e4c a.out
(You can ignore that -finline-functions-called-once option.  It didn't work, and I had to use other means to make sure the functions were inlined.  There may be some combination of gcc options that would have done it without modifying the ST source, which would have been nice, but I got tired of searching for the magic combo.)
(an empty program compiles to 1680 bytes, so 300 bytes smaller of the ~1140 of "user code" is pretty significant.")
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #190 on: September 24, 2014, 06:19:21 am »
Forum member hanging on every word here.  Nice going, guys.  Keep it up.  Just finished building a monster dev board of my own, so I'm about to dive into ARM head-first.  Stuff like this helps me acclimate to the hardware and terminology, if nothing else.

Not sure how much ASM I'll end up using, but there seems to be the possibility of sending impromptu instructions directly to RAM from the bootloader ROM on the LPC, and then immediately executing that code.  Seems like it could be a fun way to test out small snippets of code with nothing more than an FTDI cable and serial console.  If it works, it could be a cheap and easy alternative to using a full IDE and JTAG debugger.  (Not necessarily a better way, but whatever.)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #191 on: September 24, 2014, 08:28:23 am »
Oops.  Here's an update on the peripheral lib size thing.  I had left out some switches and was compiling for 32bit ARM instead of Cortex, and it turns out that it's pretty easy to supres the startup file inclusion so you can look at just the user code.  With those changes, the absolute size difference decreases, but the percentage decrease increases.
Code: [Select]
;;; Libraries...
BillW-MacOSX-2<10078> /usr/local/armgcc/bin/arm-none-eabi-gcc -I . -DSTM32F10X_MD=1 -include assert.h -ffunction-sections -fdata-sections -nostartfiles -O3 -g -Wl,--gc-sections -mcpu=cortex-m3 -mthumb main.c stm32f10x_rcc.c stm32f10x_usart.c
BillW-MacOSX-2<10079> /usr/local/armgcc/bin/arm-none-eabi-size a.out
   text    data     bss     dec     hex filename
    596      36       0     632     278 a.out

BillW-MacOSX-2<10088> /usr/local/armgcc/bin/arm-none-eabi-nm -S a.out |grep " T "
000080d0 00000018 T RCC_APB1PeriphResetCmd
000080b8 00000018 T RCC_APB2PeriphResetCmd
00008024 00000094 T RCC_GetClocksFreq
000080e8 000000b0 T USART_DeInit
00008198 000000bc T USART_Init
0000801c 00000006 T _start
00008000 0000001c T main

;;; inline functions
BillW-MacOSX-2<10080> /usr/local/armgcc/bin/arm-none-eabi-gcc -I . -DINCC=1 -DSTM32F10X_MD=1 -include assert.h  -mcpu=cortex-m3 -mthumb  -finline-functions-called-once -ffunction-sections -fdata-sections -O3 -g -nostartfiles -Wl,--gc-sections main.c
BillW-MacOSX-2<10081> /usr/local/armgcc/bin/arm-none-eabi-size a.out
   text    data     bss     dec     hex filename
    356      36       0     392     188 a.out

BillW-MacOSX-2<10090> /usr/local/armgcc/bin/arm-none-eabi-nm -S a.out |grep " T "
000080c8 00000094 T RCC_GetClocksFreq
0000815c 00000006 T _start
00008000 000000c8 T main
Note that USART_DeInit calls the RCC_APBxPeriphResetCmd functions, and the inline version successfully eliminates this second level of call as well.  USART_Init calls the GetClocksFreq function...

 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #192 on: September 24, 2014, 05:21:41 pm »
I'm trying to reproduce  your original snippet but get millions of errors. The same configuration was compiling fine for me via CLI last time I tried couple weeks ago and I'm not sure what changed. Could you provide a bit more detail on the setup? 300 bytes means almost nothing on a 128k chip but when you get down to 4k devices it could become very important. I'm just getting into stm8 (100pcs $21 shipped) and lament the lack of GCC support.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #193 on: September 24, 2014, 05:48:52 pm »
Just finished building a monster dev board of my own, so I'm about to dive into ARM head-first.

Thanks for the inspiration. I got dragged into this by the old RC controller project and now the "Zapta Challenge" definitely has me hooked.  8 bit world has been my tramping ground but lately 90% of my time in 32 bit. I got a ton of different breakout boards here and looking around at other potential ARM candidates that are cheap and have serial bootload. Can you flash all the LPC via serial like ST? What chip are you using? Package? Source?
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #194 on: September 24, 2014, 07:22:34 pm »
Oh, I agree completely that the size difference is irrelevant on most of the intended target CPUs.  But the style seems to be pretty common in the ST library, and it's exactly the sort of thing that causes one to lose confidence in the provider.  It's nice that they provide an extensive library, and it's wonderful that it includes source code, but ...  I like other peoples' code to be as good as what I'd write (even better: as good as I think my code is :-))  When I can look at the source and immediately find things that make me cringe, that's ... not good.

Quote
Could you provide a bit more detail on the setup?
Sure.  It violates your 1-minute download rule, though...  (actually, I guess I can zip up the directory I ended up with and attach it.)

I downloaded the ARM Gnu C compiler from the ARM link that someone posted early in the thread.
And I downloaded the ST Nucleo Firmware (STM32_Nucleo_FW_V1.2.1) from ST; this includes the peripheral library and its source code.  (it is actually called stsw-stm32143 and is downloadable from here: http://www.st.com/web/en/catalog/tools/PF260215# IIRC, it was a little hard to find...)

Since I didn't want to actually search the full ST libraries, or rely on anything pre-compiled, and I was suspecting I might need to modify the sourcecode, I copied all the relevant files into my working directory.  That was derived more-or-less by trial and error and ended up something like:
Code: [Select]
cp /Downloads/STM32_Nucleo_FW_V1.2.1/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c  .
cp /Downloads/STM32_Nucleo_FW_V1.2.1/Libraries//STM32F10x_StdPeriph_Driver/inc/stm32f10x_usart.h .
cp /Downloads/STM32_Nucleo_FW_V1.2.1/Libraries/CMSIS/Include/core_cm3.h .
cp /Downloads/STM32_Nucleo_FW_V1.2.1/Libraries/CMSIS/Include/core_cmInstr.h .
cp /Downloads/STM32_Nucleo_FW_V1.2.1/Libraries/CMSIS/Include/core_cmFunc.h .
cp /Downloads/STM32_Nucleo_FW_V1.2.1/Libraries/CMSIS/Device/ST/STM32F10x/Include/system_stm32f10x.h .

So then the compile command decomposes as:
Code: [Select]
/usr/local/armgcc/bin/arm-none-eabi-gcc
   -I . # Use . as search path, even for system include files
   -DSTM32F10X_MD=1     # Tell the ST lib files what kind of chip I'm using.
   -include assert.h    # I couldn't (quickly) figure out where the st files
        # sucked in their definition of "assert", which they
# use extensively (and well, I guess.)  So I wrote my
# own "null" version, and this #includes that at the
# start of the preprocessing.
   -O3 -ffunction-sections -fdata-sections -Wl,--gc-sections  # optimization
   -g  # extra symbols, so dissassemly works better.
   -nostartfiles # Supress the normal startup files
   -mcpu=cortex-m3 -mthumb  #  What kind of chip I'm using
   -DINCC=1     # if part of the compile command, tells main.c to
    #  #include the ST .c files, giving the compiler a
#  fair chance of inlining some of the functions
# if omitted, I compile the ST files separately and
#  link them in (sort of) like libraries.
# (I'm pleased that this worked as well as it did!)
    main.c stm32f10x_rcc.c stm32f10x_usart.c
        # list of c files (only put main.c here if INCC is set.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #195 on: September 25, 2014, 12:51:02 am »
Thanks. Among other things that HAL package was one of the missing pieces of the puzzle.

BTW I think I have a handle on the  ADC stuff now. Although it wasn't part of the original plan, along with the serial routines might even attempt a useful application. Maybe primitive scope or logic analyzer or something. Not even close to those $50 ARM pocket deals but just to see what can be done without FPGA or other external hardware. If nothing else then just to poo-poo  naysayers who insist this is not possible.
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #196 on: September 25, 2014, 06:00:14 am »
Thanks for the inspiration. I got dragged into this by the old RC controller project and now the "Zapta Challenge" definitely has me hooked.  8 bit world has been my tramping ground but lately 90% of my time in 32 bit. I got a ton of different breakout boards here and looking around at other potential ARM candidates that are cheap and have serial bootload. Can you flash all the LPC via serial like ST? What chip are you using? Package? Source?

I have completely different motives than you -- for one, I'm not putting up any barriers to cost or ease of reproduction.  But, my goal is similar.  I'm currently not an expert at.. anything really.. but I'm enthusiastic and want to contribute to the micro community from which I've gained so much.  This project, for me, is half skill builder, half practical product.

As for being able to flash "all" the LPCs via UART?  Not sure.  I have on-hand some LPC4078 (LQFP-100), LPC812 (TSSOP-20), and an Xpresso board with an 1115 IIRC (haven't used it yet.)  The 40xx and 8xx series, at least, have ROM bootloaders with UART support, and I get the impression that's the norm.  So, if not all of them, at least the modern ones should.

Ideally, I want to do something similar to what you guys are doing (focused on C though), and start publishing info on how to get started with a blank IC, a code editor of your choice, a minimal GNU toolchain, and an FTDI cable.  Low barrier-to-entry stuff, with a solid understanding of what does what.

To that end, I'm working on code to do PC-to-IC and IC-to-IC ISP via UART.  (Yes, I'm reinventing some wheels here, but that's part of my process.  If you can write functional code from scratch, you probably have a fairly solid understanding of the concept in question.)  Then, I want to sort out the basic dependencies, and where to get them.  (Haven't completely sorted out where to get libraries that are essentially freely redistributable.  Extract from vendor tools?  Reference code from ARM?  Do I have to write those from scratch and release into public domain?)  Then, I want to bring in the typical building blocks -- FreeRTOS, lwIP, USB stack, etc.

This is all iterative, and once I an OS with IP stack running, my dev board turns into a useful device, and I'll have enough experience to help others figure out how to turn parts into products of their own.  (Assuming some electronics background.  I'm still far from qualified to teach those skills, though I might publish what I know and let the Internet correct me any time I'm wrong.  I just want to avoid leading people astray.)
« Last Edit: September 25, 2014, 06:17:21 am by SirNick »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #197 on: September 26, 2014, 07:44:01 pm »
I want to do something similar to what you guys are doing (focused on C though), and start publishing info on how to get started with a blank IC, a code editor of your choice, a minimal GNU toolchain, and an FTDI cable.

I would love to see that happen particularly in view of key words "GNU" and "FTDI". I haven't had much time to investigate in detail but after browsing specs I ordered a few LPC812M101JD20FP from Mouser. Not much more than a dollar each so fits right into my area of interest for this thread. There's a big stack of blank breakout boards sitting here waiting. Have you compiled or flashed any chips yet? Is there a small programming utility similar to ST flash demo or STVP?
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #198 on: September 27, 2014, 08:16:56 am »
You know what, I think I'll start a new thread on my project.  Don't want to disrupt the momentum you guys have going.

http://www.eevblog.com/forum/microcontrollers/lpc-from-scratch/
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #199 on: September 28, 2014, 03:35:49 am »
I don't see the F103 as much superior in every respect, nor do I even see them costing less.
...
F030's for $0.70, yes.

You are right, it's probably not a good idea to compare ST chips in the LPC thread so here we are.

I might be wrong and open to education. Admit not pouring over F030 specs but just listening to ghetto talk. Can you be more specific about the advantages of F030? Also my shopping for that has only been Ebay type sites where they are quite expensive so could use a link to  70 cents.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #200 on: September 28, 2014, 04:00:30 am »
I don't see the F103 as much superior in every respect, nor do I even see them costing less.
...
F030's for $0.70, yes.

You are right, it's probably not a good idea to compare ST chips in the LPC thread so here we are.

I might be wrong and open to education. Admit not pouring over F030 specs but just listening to ghetto talk. Can you be more specific about the advantages of F030? Also my shopping for that has only been Ebay type sites where they are quite expensive so could use a link to  70 cents.

What now? You say F103 is cheaper than F030. That is easy enough for me to check (and exploit by pressing BUY NOW). Explaining what I like about chip #1 vs chip #2 for a few projects takes far longer. :P

You have PM with link to $0.70 goodies.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #201 on: September 28, 2014, 04:25:45 am »
Short version of why F030 instead of F103:

For a given cost of the chippies:
number of timers + usable PWM pins + usable ADC channels while still having an USART + debug interface. Basically cost per PWM output + ADC input pair, while still maintaining a decent adc converter per adc channels ratio. PWM has to be center aligned, so that limits the timer to advanced or some of the general timers.

And then all things considered, including but not limited to price, the F030 turns out to be "better" than F103. So in this case better happens to be how many of resource type XYZ can you actually use, while not getting IO pin collisions with that other resource. And I've seen enough MCU's where that turns out to be a depressingly low ratio.

But overall, the F103 datasheet has larger numbers in it. No denying that. It's just that useful pins + used peripherals / $$$ turns out better for F030 in more than zero cases.

Anyways, I like the F103 as well and intend to plonk it in some other projects. As far as I'm concerned it is not so much this is better than that PERIOD. It's just that for one use case one chip turns out better, and for another use case the advantage goes to some other chip. At the moment I mainly muck about on ST chips, and TI to a lesser extent. Only so much time in the day to familiarize yourself with a new vendor's goodies.

On the list of possibly fun to try are those NXP's (have been there for a long time now ;) ) and those damn cute PSOC's. Although to be fair the PSOCs stand a better chance of being ordered since they actually bring some new solutions to the toolbox. LPC would just be more of the same (for me). But that doesn't stop me from reading other people's exploits on those, because who knows what cool stuff they find. ;D
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #202 on: September 28, 2014, 07:13:35 pm »
You have PM with link to $0.70 goodies.

Thanks for that. However maybe you overlooked the shipping charges there which bring actual cost to $.90. Still a good deal but I'm spoiled by being lucky to snag 103 for a dime cheaper ($.80). I realize this is not a fair comparison because of quantity and not just a click on "buy now". F0 not being a commodity item is not available through that channel. But maybe you can see why I don't consider those a bargain.

Speaking of comparisons, I want to thank you for motivating me to finally cruise that spec sheet too. Here's a little summary table I spent a couple minutes throwing together:

Code: [Select]
STM32F103C8T6 STM32F030F4P6
M3            M0
72mhz         48MHz
128KB flash   16KB
3 UART        1 UART
36 io         15
20K ram       4K

There's more but probably enough to allow most readers to decide which is the "better" chip. Considering cost is similar and 103 is orders of magnitude more available I've made up my mind.

BTW as far as pin/function mapping I find it hard to imagine the 20 pin crippled chip has advantages over the 48 pin in that area. I spent some time but couldn't find a single example. But we do agree totally on the exception for "more than zero cases". It may be possible the 20 pin has a leg up in terms of PCB routing in some rare design but for the other 99% the 103 would usually do. One can always ignore features not needed but hard to make use of those not present.

ps. LPC parts came in and it was surprising to see the 20 pin SMD package was actually bigger than the 48 pin 103, a  LOT bigger.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #203 on: September 29, 2014, 12:06:43 am »
This is probably best answered here because someone else just asked a similar question.

Quote
Not much more than a dollar each at Mouser? Including shipping cost? Woah!
*ducks for cover*

Yes.

http://www.mouser.com/ProductDetail/NXP/LPC812M101JD20FP/?qs=%2fha2pyFadujd6Yxbwm6s6vWcdu8reqzbi4ydgJDibZaEL%2f0jTMWFtw%3d%3d

In this case I followed the "Fribble Method" of minimizing expense by tacking onto a large order so shipping worked out to about 3 cents each. Even without this total cost would still be a dollar and change. The chips have actually arrived now. Next step lets see if we can manage to program these with same minimum tools as the ST parts.
« Last Edit: September 29, 2014, 12:28:33 am by paulie »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #204 on: September 29, 2014, 04:10:03 am »
This is promising. I've hooked one of these up to the PC and it seems to be responding to serial commands as described by SirNick at the beginning of his C/Unix thread. Now to see if the Flashmagic utility sca gave me works to upload a hex file. All I have ATM are ones that were assembled for the ST chips so can't expect it to do anything but it will be a good sign if there are no error messages.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 15412
  • Country: nl
    • NCT Developments
Re: One Dollar One Minute ARM Development
« Reply #205 on: September 29, 2014, 07:41:06 am »
Hmmm, NXP cared to put a 30MHz ARM microcontroller in a DIP8 package.
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 #206 on: September 30, 2014, 01:59:08 am »
PSOCs stand a better chance of being ordered since they actually bring some new solutions to the toolbox.

That's what I thought. I bought the $4 dev board and a few chips then found out there is no bootloader. The break-in-half board is nothing more than a USB/serial so that can't be used to flash them either. More money for a custom programming dongle? Nope. Back in the junk box.

Looks like STM and LPC may be the only solution for low cost ARM experiments.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #207 on: September 30, 2014, 03:08:02 am »
That's what I thought. I bought the $4 dev board and a few chips then found out there is no bootloader. The break-in-half board is nothing more than a USB/serial so that can't be used to flash them either. More money for a custom programming dongle? Nope. Back in the junk box.
Using the ~ $25 pioneer board as programmer has been mentioned a few times by miguelvp. Your call if $25 is acceptable for a dev board that can double as programmer for those $4 boards.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #208 on: September 30, 2014, 05:36:46 am »
PSOCs stand a better chance of being ordered since they actually bring some new solutions to the toolbox.

That's what I thought. I bought the $4 dev board and a few chips then found out there is no bootloader. The break-in-half board is nothing more than a USB/serial so that can't be used to flash them either. More money for a custom programming dongle? Nope. Back in the junk box.

Looks like STM and LPC may be the only solution for low cost ARM experiments.

How much do you want for your junk?

Btw you can use the $4 dev board to program (not debug) the other chips.

http://www.cypress.com/?id=4&rID=98796

Edit: The $25 Pioneer can also debug the code on the chips, but to just program it, the $4 breakout board will do.

Edit2: Also you can use Keil to program (And Debug) the chip:

http://www.eevblog.com/forum/microcontrollers/one-dollar-one-minute-arm-development/msg515630/#msg515630

But if you use ulink make sure you apply power to the chip because it doesn't supply power.
« Last Edit: September 30, 2014, 06:34:31 am by miguelvp »
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #209 on: September 30, 2014, 07:43:33 am »
LOL  Man.. if I ever sell products, I'm going to hire you guys to be my parts shoppers.  I'm too lazy.. I just go to Digikey and pick what I want, and grumble if I'm "forced" to second-source stuff from Mouser.  ;)

Hey, Paulie.. if you or westfw end up with an ASM file for the 812, let me know.  I could use something to test the bootloader code I'm working on, and don't want to get distracted going down the rabbit hole of writing a proper test app just yet.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #210 on: September 30, 2014, 01:42:45 pm »
Btw you can use the $4 dev board to program (not debug) the other chips.

I don't think that's the case. First of you should know the CY8CKIT-049 "programmer" is nothing more than a USB/serial interface and requires the target to have a built-in bootloader. As mentioned last time we discussed this the target chip on the 049 obviously has one but it is not one of the $1 parts included in the promotion.

I spent quite a lot of time investigating this and at best came up with several links explaining how to compile and install a custom bootloader using a programmer that has true SWD flashing capability like the miniprog3 or pioneer. These are quite costly for my purpose. Your link showing how to build a programmer using parallax stamp was similar to others that didn't look cheap or easy to implement either.

Next in conversations with Cypress FAE at digikey was told the 4200 chips I purchased did not have boot code installed. Other more expensive versions do.

Finally cypress documentation AN84858 states:
Quote
b. Bootloaders can use any standard communication interface (e.g., USB, I2C, SPI, and UART) to update the firmware. But HSSP uses an SWD or JTAG interface to program the flash. PSoC 4 supports only SWD interfaces.

There were a few more hints in this direction but along with high cost after promotion ($4-$5 each) I decided these were not worth pursuing  as a low cost ARM option for casual experimentation. If you have any convincing evidence to the contrary I would be very appreciative as there's still a few sitting around here gathering dust.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #211 on: September 30, 2014, 02:16:38 pm »
Btw you can use the $4 dev board to program (not debug) the other chips.

I don't think that's the case. First of you should know the CY8CKIT-049 "programmer" is nothing more than a USB/serial interface and requires the target to have a built-in bootloader. As mentioned last time we discussed this the target chip on the 049 obviously has one but it is not one of the $1 parts included in the promotion.

Ok, the CY8CKIT-049 is a USB/serial interface and does require the target to have a built-in bootloader, and as you mention the chip built into the 049 has the bootloader programmed.

The link I gave:
http://www.cypress.com/?id=4&rID=98796

Uses that 4200 inside the 049 to program an external chip that doesn't have a bootloader and it's factory virgin, so you can program the 2nd external 4200 (or 4100, or whatever).

The program in there uses the on board 4200 pins P2.0 for SWDIO, P2.1 for SWDCK and P2.4 for XRES_n on the protoboard to connect to the external chip. You hook those to the virgin 4200 on P3.2 for SWDIO, P3.3 for SWCLK and the appropriate XRES pin (depends on what chip you have (pin 33 on the 44-TQFP, pin 30 on the 40-QFN or pin 25 on the 28-SSOP packages).

So I'm not talking about using just the USB-UART part of the board, but the whole prototype board to program the external virgin chip.

Quote
I spent quite a lot of time investigating this and at best came up with several links explaining how to compile and install a custom bootloader using a programmer that has true SWD flashing capability like the miniprog3 or pioneer. These are quite costly for my purpose. Your link showing how to build a programmer using parallax stamp was similar to others that didn't look cheap or easy to implement either.

Do you have any current programmers listed here?


If you do then you can use Kiel to program and debug the chip. Otherwise you can use the prototype CY8CKIT-049 42xx board as stated.

Quote
Next in conversations with Cypress FAE at digikey was told the 4200 chips I purchased did not have boot code installed. Other more expensive versions do.

Finally cypress documentation AN84858 states:
Quote
b. Bootloaders can use any standard communication interface (e.g., USB, I2C, SPI, and UART) to update the firmware. But HSSP uses an SWD or JTAG interface to program the flash. PSoC 4 supports only SWD interfaces.

There were a few more hints in this direction but along with high cost after promotion ($4-$5 each) I decided these were not worth pursuing  as a low cost ARM option for casual experimentation. If you have any convincing evidence to the contrary I would be very appreciative as there's still a few sitting around here gathering dust.

what $1 chips did you get (package information) and what prototype board did you get (41xx or 42xx)?
Because the project in that link is easier on the 42xx board.

The project in that link "4 dollar programmer.zip" should be able to program (not debug) the external virgin $1 chip with any .hex file that is compiled for that external chip.


Edit: for example I did program this chip with the Pioneer, and it was one of those $1 chips, I can reprogram it using the $4 42xx prototype board and document the steps if you like.
It doesn't have a bootloader because I didn't wire a button to activate the bootloader on it nor a bootloader status led for that matter.


« Last Edit: September 30, 2014, 02:42:46 pm by miguelvp »
 

Offline Laurynas

  • Contributor
  • Posts: 47
  • Country: lt
Re: One Dollar One Minute ARM Development
« Reply #212 on: September 30, 2014, 03:55:42 pm »
Btw you can use the $4 dev board to program (not debug) the other chips.

http://www.cypress.com/?id=4&rID=98796

Edit: The $25 Pioneer can also debug the code on the chips, but to just program it, the $4 breakout board will do.

Nice find!
I was using my Pioneer as a programmer, but it's nice to see that usb->serial->1$ PSoC->SWD programmer is implemented.
I wonder if this would work with 4000 series basic chips :)
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #213 on: September 30, 2014, 04:06:20 pm »
Btw you can use the $4 dev board to program (not debug) the other chips.

http://www.cypress.com/?id=4&rID=98796

Edit: The $25 Pioneer can also debug the code on the chips, but to just program it, the $4 breakout board will do.

Nice find!
I was using my Pioneer as a programmer, but it's nice to see that usb->serial->1$ PSoC->SWD programmer is implemented.
I wonder if this would work with 4000 series basic chips :)

As the target yeah, but not as the programmer since you need the UART and the UART SCB mode components which they won't be present in the 4000 series.

I know they are present in the 4200 I hope they are in the 4100 as well.

Edit: BTW, are you using the pioneer as a programmer debugger or just as a programmer? the reason I ask is because there is a way to use it as a miniprog 3 if you are interested.
« Last Edit: September 30, 2014, 04:09:58 pm by miguelvp »
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #214 on: September 30, 2014, 05:29:05 pm »
Ok, didn't do the detailed in-depth yet but just wanted to make sure it worked.

Caveat: and a big one! the project is not a bootloadable one so once you program your $4 prototype board you can't restore it unless you have another $4 board or a $25 Pioneer or a $90 miniprog, or other programmers including Altera and Xilinx programmers among the ones supported by Keil, but I only have the Pioneer and the $4 prototype board (2 of them one 42xx the other 41xx and I haven't tried it with the 41xx yet).

So I took the project and built it, boot loaded it into the prototype board.

Then I made a blinky program for the external chip and uploaded the .hex code following the instructions.
wired the VDD, GND, XRES, SWDIO & SWDCLK



And it runs the blink program on the external chip just fine



Again, this will disable the bootloadable code on the prototype kit, I guess I can work on making the $4 programmer code bootloadable so you don't brick the prototype board.

I can recover it because I have the pioneer to override the code, but in any event, once you program the prototype kit as a programmer you can use it indefinitely by changing the python script to point to a different hex file to program your target chip.

Edit2: One more caveat, unless you put the right decoupling caps to use the internal regulator, you have the choice of shorting pins but then you have to feed it 1.8V +- 5% available on the VCCD pin but that is not exposed on the headers and it just goes to C1, I guess you can solder a wire to get the VCCD 1.8 rectified voltage if you decide to short the target chip pins to use the external regulated supply.

But might as well put the decoupling caps so you can feed anything from 1.8V to 5.5V.

« Last Edit: September 30, 2014, 05:44:29 pm by miguelvp »
 

Offline Laurynas

  • Contributor
  • Posts: 47
  • Country: lt
Re: One Dollar One Minute ARM Development
« Reply #215 on: September 30, 2014, 05:47:12 pm »
Nice find!
I was using my Pioneer as a programmer, but it's nice to see that usb->serial->1$ PSoC->SWD programmer is implemented.
I wonder if this would work with 4000 series basic chips :)

As the target yeah, but not as the programmer since you need the UART and the UART SCB mode components which they won't be present in the 4000 series.

I know they are present in the 4200 I hope they are in the 4100 as well.

Edit: BTW, are you using the pioneer as a programmer debugger or just as a programmer? the reason I ask is because there is a way to use it as a miniprog 3 if you are interested.

4100 series have SCBs so they should work here. But I just wish that someone would write a decent software UART (not just TX that cypress has as standard component.) this way we could make some use of ARM core and get this into 8 pin minimal devices. (not that it has some real cost advantage, just for fun:))
As for pioneer I soldered some wires where the resistors were so it works like a proper debugger.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #216 on: September 30, 2014, 05:58:53 pm »
As for pioneer I soldered some wires where the resistors were so it works like a proper debugger.

You'll be interested then in this:
http://www.element14.com/community/thread/27067/l/psoc-5lp-programmer-firmware

On the 2nd page I modified the released 2.03 KitProg code to use the 5LP header to drive the SWDIO and SWDCLK, also not in there I changed the version.h code to force it to 2.08 so that it works with other cypress tools.

http://www.element14.com/community/thread/27067?start=15&tstart=0
« Last Edit: September 30, 2014, 07:08:04 pm by miguelvp »
 

Offline Laurynas

  • Contributor
  • Posts: 47
  • Country: lt
Re: One Dollar One Minute ARM Development
« Reply #217 on: September 30, 2014, 06:41:32 pm »
bookmarked :)
much more work done than soldering, but looks much better than my solution.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #218 on: September 30, 2014, 07:15:24 pm »
bookmarked :)
much more work done than soldering, but looks much better than my solution.

Not really more work, I just changed two pins on the cydwr file so it will use the 5LP header pins for SWDIO and SWDCLK and the version number, also prevented the bootloader/bootloadable modules to upgrade past version 1.1 and the USBFS to leave them at 2.51 or 2.50 where 2.51 was not an option.
 

Offline Laurynas

  • Contributor
  • Posts: 47
  • Country: lt
Re: One Dollar One Minute ARM Development
« Reply #219 on: September 30, 2014, 08:26:34 pm »
bookmarked :)
much more work done than soldering, but looks much better than my solution.

Not really more work, I just changed two pins on the cydwr file so it will use the 5LP header pins for SWDIO and SWDCLK and the version number, also prevented the bootloader/bootloadable modules to upgrade past version 1.1 and the USBFS to leave them at 2.51 or 2.50 where 2.51 was not an option.

By changing version number you are telling PC that it's using new firmware while it does not do so.
While this will work in most cases, some risk exists unless cypress keep updating their programmer code source.
Soldering 3 wires is a less risky solution, but it makes pioneer kit unusable without re-soldering resistors.

Anyway this PSoC 4 programmer code and your PSoC5 changes are progress towards AVR style cheap dev tools. And that is important to attract more devs to this great architecture.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #220 on: September 30, 2014, 09:32:51 pm »
what $1 chips did you get (package information) and what prototype board did you get (41xx or 42xx)?

42xx board and CY8C4245PVI-482 chips so my prototype looks exactly like yours. It seems that two of your solutions will work for super low cost programming. Reprogramming the kit board will keep cost to $4 which is well within my budget and would fit right into the purpose of this thread. Because they referred to the board as "Stamp" I initially confused it with the Parallax product so didn't appreciate this approach. Definitely worth a try.

More importantly the ability to use an STlink dongle is great news because a couple of those were purchased, one on Ebay for $5 and another on Aliexpress for $4. This last solution is by far the easiest since there are no modifications involved. Installing the Keil package on my netbook  is a bit of a pain but when the LPC and STM8 projects are done this may be next.

Thanks for taking time to explain this and hopefully more details and discussion are coming.
« Last Edit: September 30, 2014, 10:03:43 pm by paulie »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #221 on: September 30, 2014, 09:55:04 pm »
I just go to Digikey and pick what I want, and grumble if I'm "forced" to second-source stuff from Mouser.

For me it's the other way around. Mouser prices are significantly less than Digikey (although pressed they will usually match) but the clincher is inability to use Paypal at  Digikey. My account always has balance so fees are avoided and I'm very fond of the protection policy which has saved my butt more than once.

Hey, Paulie.. if you or westfw end up with an ASM file for the 812, let me know.

I have a package with linker script, source, and hex identical to the ST one on first post here but for LPC. I was planning to put up the ST8 stuff first and don't know if it will be timely or useful to you but will see if I can dig out the LPC version when i get home.

don't want to get distracted going down the rabbit hole of writing a proper test app just yet.

Too much time watching Matrix movies? Take the blue pill. :)
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #222 on: September 30, 2014, 10:14:17 pm »
if $25 is acceptable for a dev board that can double as programmer for those $4 boards.

If these were to be used for serious development, even for hobby use, that would make sense. In my case 8 bit is still my main arena  and ARM is just  casual experimentation. There are so many families and variations cost would quickly add up. Already over a dozen different parts from 4 manufacturers and it ain't over yet so we would be talking big money if I adopted this mindset:

their programming dongles are $40 and a dev board is usually less than $100.

He considered that a bargain. I suppose it sounds great compared to the old days when hundreds for hardware and thousands for software were the norm but not in my case which is just for curiosity and fun.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #223 on: October 01, 2014, 12:49:26 am »
By changing version number you are telling PC that it's using new firmware while it does not do so.
While this will work in most cases, some risk exists unless cypress keep updating their programmer code source.
Soldering 3 wires is a less risky solution, but it makes pioneer kit unusable without re-soldering resistors.

Anyway this PSoC 4 programmer code and your PSoC5 changes are progress towards AVR style cheap dev tools. And that is important to attract more devs to this great architecture.

I agree, I had it as 2.03 since most of the toolchain will just complain that is not up to date but that's fine, the only piece of software that refused to work was the bridge control panel that would not connect unless the kitprog was on the latest version. That's the reason I changed it and I can communicate with the external chip via I2C etc via the 5LP.

@paulie

I will work on a bootloadale version of the $4 programmer, and add more detail on the process.
Also I want to note that after the promotion ($1 which today is the last day) they wont go to $4-$5 a pop, regularly the one you got is $2.49 qty 1 I believe.

I'll add more details on the third party programmers but I don't have an st-link so I can't tell if that will work for sure until someone tries. You can create the full project in Creator including programming the UDBs and then export to keil and theoretically you should be able to use the supported programmers. The  application note regarding uVision only used ulink pro, but that doesn't mean the other ones won't work.

In theory you can use any micro controller to program the chip via SWD.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #224 on: October 01, 2014, 10:44:23 am »
So I did look more into the project and it does have the bootloader already in there, weird they don't have the source for it just the hex file as a dependency.

But if I press the user button while powering it with the programmer installed it does blink and it will accept a new bootloadable program.

The first time I did try, I used the prebuild one in there and that bricked the prototype board, but I did reset it back with the pioneer.

So you have to load the 4 dollar programmer project and upgrade the components build it and then program the board.

I'll do a step by step instructions shortly.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #225 on: October 01, 2014, 03:46:21 pm »
Quote
Code: [Select]
STM32F103C8T6 STM32F030F4P6

128KB flash   16KB
Technically, the STM32F103C8t6 only has 64k of flash.


WRT in-lining the standard peripheral library:

It turns out that there is a simpler way to get partly optimized code.  Simply include the .c file from the STP modules as well as the .h files:
Code: [Select]
#include "stm32f0xx_rcc.h" //clock routing used
#include "stm32f0xx_gpio.h" //gpio modules used
#include "stm32f0xx_adc.h" //adc module used
#include "stm32f0xx_usart.h" //usart used
#include "stm32f0xx_misc.h" //interrupts used

#ifdef DOINLINE
#include "stm32f0xx_rcc.c" //clock routing used
#include "stm32f0xx_gpio.c" //gpio modules used
#include "stm32f0xx_adc.c" //adc module used
#include "stm32f0xx_usart.c" //usart used
#endif

Doing this for Dannyf's init/adc/uart blinky program shaved off a bit more than 10%, which isn't bad for an essentially zero-effort change.  It didn't improve any using modified STP files, either.  (However, the simple uart deinit/init example, which was crafted to explicitly capitalize on the inline definitions, DID do much better with modified STP source - it only went down about 5% in size with the double-includes.  I'm not sure exactly why...)

Code: [Select]
BillW-MacOSX-2<10307> make dannyn
/usr/local/armgcc/bin/arm-none-eabi-gcc -DSTM32F10X_MD=1 -mcpu=cortex-m3 -mthumb -O3 -ffunction-sections -fdata-sections -Wl,--gc-sections -gdwarf-2 -include assert.h -o danny_normal -DSTM32F030=1 \
           -I normal danny.c \
           normal/stm32f0xx_misc.c normal/system_stm32f0xx.c \
           normal/stm32f0xx_usart.c normal/stm32f0xx_rcc.c \
           normal/stm32f0xx_adc.c normal/stm32f0xx_gpio.c
/usr/local/armgcc/bin/arm-none-eabi-size danny_normal
   text    data     bss     dec     hex filename
   3288    1120      40    4448    1160 danny_normal
BillW-MacOSX-2<10308> make dannyi2
/usr/local/armgcc/bin/arm-none-eabi-gcc -DSTM32F10X_MD=1 -mcpu=cortex-m3 -mthumb -O3 -ffunction-sections -fdata-sections -Wl,--gc-sections -gdwarf-2 -include assert.h -o danny_i2 -DSTM32F030=1 \
           -I normal -DDOINLINE danny.c \
           normal/stm32f0xx_misc.c normal/system_stm32f0xx.c
/usr/local/armgcc/bin/arm-none-eabi-size danny_i2
   text    data     bss     dec     hex filename
   2900    1120      36    4056     fd8 danny_i2

 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #226 on: October 01, 2014, 04:09:47 pm »
42xx board and CY8C4245PVI-482 chips so my prototype looks exactly like yours. It seems that two of your solutions will work for super low cost programming. Reprogramming the kit board will keep cost to $4 which is well within my budget and would fit right into the purpose of this thread. Because they referred to the board as "Stamp" I initially confused it with the Parallax product so didn't appreciate this approach. Definitely worth a try.

More importantly the ability to use an STlink dongle is great news because a couple of those were purchased, one on Ebay for $5 and another on Aliexpress for $4. This last solution is by far the easiest since there are no modifications involved. Installing the Keil package on my netbook  is a bit of a pain but when the LPC and STM8 projects are done this may be next.

Thanks for taking time to explain this and hopefully more details and discussion are coming.

This is a link to part one out of three, in here i'm just creating the target program for the virgin chip.

http://www.eevblog.com/forum/microcontrollers/psoc-examples/msg522554/#msg522554

Next I'll put the steps to program the prototype board to act as a programmer

and after that I'll put the steps to use the programmer to program the code from part 1 into a virgin chip that has no bootloader on it.

(I might do part two now, or maybe tomorrow since it's 1 AM already)

 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #227 on: October 01, 2014, 06:28:41 pm »
Oh well, decided to stay up (it's 3:30 AM now) but I have all three parts posted in there:
http://www.eevblog.com/forum/microcontrollers/psoc-examples/msg522554/#msg522554
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #228 on: October 01, 2014, 10:50:38 pm »
That's pretty impressive. You have proven we dont have to end up in the poorhouse to play with PSOC4 either. I plan to try this out myself as soon as my STM8 and LPC projects are done. Only one GUI based setup at a time fits in the limited SSD space on my day computer which is a netbook. I wonder if there might be a small flash utility hidden somewhere inside the Keil or Creator package. This would allow me to fit PSOC in with the other minimal GCC toolsets like I've done with STM and LPC.

So far it looks like we have 3 members of the $1 one minute ARM club: ST, LPC, and PSOC. Maybe there are others hiding out there too.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #229 on: October 02, 2014, 05:35:47 am »
Quote
Code: [Select]
STM32F103C8T6 STM32F030F4P6

128KB flash   16KB
Technically, the STM32F103C8t6 only has 64k of flash.
Indeed. And 37 gpio.

The STM32F103RET6 is the one in the bigger package with 128k flash.

 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #230 on: October 02, 2014, 05:38:06 am »
Oh well, decided to stay up (it's 3:30 AM now) but I have all three parts posted in there:
http://www.eevblog.com/forum/microcontrollers/psoc-examples/msg522554/#msg522554
And thank you very much for posting all that. Those posts just made a psoc buying incident very very likely. ;)
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #231 on: October 02, 2014, 07:22:16 pm »
The STM32F103RET6 is the one in the bigger package with 128k flash.

STM32F103C8T6 is the one that's much cheaper in medium package with 128k flash.

Some may have noticed the PSOC promotion is over. My $1 chips would cost over $4 with shipping now so good thing I got in under the wire. It might still be worth it to me if it was possible to use STlink for programming but so far no evidence this actually works.
 

Offline Kostas

  • Regular Contributor
  • *
  • Posts: 71
  • Country: gr
Re: One Dollar One Minute ARM Development
« Reply #232 on: October 02, 2014, 07:36:00 pm »
Some may have noticed the PSOC promotion is over. My $1 chips would cost over $4 with shipping now so good thing I got in under the wire. It might still be worth it to me if it was possible to use STlink for programming but so far no evidence this actually works.

Is it over? It seems I can still buy them at $1 a piece, with free shipping. In fact, it seems I can get any ic with free shipping, but not any of the dev kits they offer.
 

Offline aon

  • Contributor
  • Posts: 30
  • Country: fi
Re: One Dollar One Minute ARM Development
« Reply #233 on: October 02, 2014, 08:58:45 pm »
So far it looks like we have 3 members of the $1 one minute ARM club: ST, LPC, and PSOC. Maybe there are others hiding out there too.

Some of the Silabs EFM32ZG chips are pretty close to a dollar (even in singles) and come with a UART bootloader for low-cost programming. But they're in QFN's which might be a show stopper for some, and availability via the inofficial channels is close to nonexistent (EDIT: actually, taobao has some things that look rather interesting, might have to look into that at some point).

Oh, and there are some cheap chips in the freescale kinetis L series as well that I've looked at. For me, the thing that separates ST from the rest is the abundance of (some variants of) the chips and cheap programming tools.
« Last Edit: October 03, 2014, 12:25:54 am by aon »
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #234 on: October 03, 2014, 01:20:31 am »
The STM32F103RET6 is the one in the bigger package with 128k flash.

STM32F103C8T6 is the one that's much cheaper in medium package with 128k flash.
Datasheet?
« Last Edit: October 03, 2014, 01:44:48 am by mrflibble »
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #235 on: October 03, 2014, 01:44:50 am »
LOL. This has been discussed here, in the ghetto thread, my RCG kinks on page one, Multiwii forum, and many other places on the internet. Contrary to specs 103c8 have 128k flash. This is easily demonstrated with the ST flash program by overriding the default 64k entry and verifying true size with "fill" and "verify" options on the next page. Also note that several commercial products depend on this overage.

It's possible that new versions may not have this bonus feature and ST may start producing chips without but IMO more likely to get hit by a meteor. Just one of the reasons this particular chip remains untouchable regarding MCU cost/benefit.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1878
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #236 on: October 03, 2014, 01:50:54 am »
I was almost waiting for it. I tend to stick with datasheets when listing features for other people's benefit, but to each their own method of presenting information.
« Last Edit: October 03, 2014, 02:04:49 am by mrflibble »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #237 on: October 03, 2014, 03:51:58 am »
Quote
Contrary to specs
It does bother me that we're ignoring datasheet specs and paying "gray market" prices that aren't reproducible from generic vendors (even in large quantities.  Mouser/digikey prices for stm32f103c8t6 are about $3 in full reels of 2400.)  Especially without obvious explanations...
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #238 on: October 03, 2014, 04:34:10 am »
It makes me wonder as well.  What benefit is there to the manufacturer to underrate the flash spec?  Strictly a yield thing?  Is flash production that prone to failure?  Hmm...

Definitely not something I would bank on, without some word from the vendor saying: "Yep.  It's here to stay.  Just too lazy to change the specs."
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #239 on: October 03, 2014, 11:57:02 am »
Unlikely ST will issue a press release saying " Yup, those $5 chips are EXACTLY the same die as the $1 chips". Unfortunately for us not a humanitarian institution totally unconcerned with profit. Instead they must have discovered that it's cheaper to maintain one product line vs two. At the risk  of upsetting again here's a couple more:

Some of the six pin "brain dead" Atmel chips have twice the stated memory too. Really. And atmel does not advertise this either.

ATMEGA328 runs fine at 16mhz on 3.3v. Over the entire temperature range.  Just like with STM32 there are some (successful) commercial products here that depend on bonus features. Not a single credible case of failure out of thousands of users.

Of course if something like military or life dependent applications are involved it might be a good idea to stick with the party line. Not so much for technical reasons but mainly to avoid vulnerability in potential tort actions. In any case I'm willing to take the hit for any tragic hobby mishaps resulting from my evil misinformation campaign.

There are generally two basic viewpoints on this subject, those who have decided datasheet is bible and those with a more atheistic attitude. Personally I am oriented more toward practice than theory. You can call it cutting corners if it makes you feel better. It's a choice and has held me in good stead so far as apparently yours has for you guys. Just my two cents, or should I say dollar and two cents. :)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 2704
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #240 on: October 03, 2014, 03:09:49 pm »
So neglecting politics, what's the next thing to implement in assembler?
 

Offline true

  • Frequent Contributor
  • **
  • Posts: 295
  • Country: us
  • INTERNET
Re: One Dollar One Minute ARM Development
« Reply #241 on: October 03, 2014, 04:46:36 pm »
Some may have noticed the PSOC promotion is over. My $1 chips would cost over $4 with shipping now so good thing I got in under the wire.
~$2.50/ea, free shipping direct from Cypress... not sure why you keep saying >= $4...
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #242 on: October 03, 2014, 04:51:55 pm »
Some may have noticed the PSOC promotion is over. My $1 chips would cost over $4 with shipping now so good thing I got in under the wire.
~$2.50/ea, free shipping direct from Cypress... not sure why you keep saying >= $4...

I know, I brought that up about 3 times already.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #243 on: October 03, 2014, 09:28:03 pm »
Because that's what mouser charged when I went back to purchase more for a friend (3.28*5=15.4 +5.99=22.39 /5= $4.48 each):

http://www.mouser.com/ProductDetail/Cypress-Semiconductor/CY8C4245PVI-482/?qs=sGAEpiMZZMuoKKEcg8mMKCq3qKLhcxNGDk4txzttb8I%3d

Closer to $5 at Digikey. If someone had mentioned here that free shipping was available from Cypress I could have cut my expenses in half.
 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #244 on: October 04, 2014, 05:33:36 am »
So neglecting politics, what's the next thing to implement in assembler?

More like religion if you ask me. I shouldn't complain because if it weren't for "white market" suckers to support development and infrastructure us black marketeers would be left out in the cold.

To answer your question I've managed to get a crude logic analyzer implemented in 103c and trying to port to STM8. 25 cent LA!

Meanwhile, in addition to the LPC demo I posted on page one earlier this week, the STM8 dummy demo in reply #5 slot has been updated with one that actually toggles the LED. Still only 3 instructions. On request a photo of the setup has been added:

 

Offline paulie

  • Frequent Contributor
  • **
  • Banned!
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #245 on: October 04, 2014, 07:45:13 am »
Some of the Silabs EFM32ZG chips are pretty close to a dollar (even in singles) and come with a UART bootloader for low-cost programming. But they're in QFN's which might be a show stopper for some,

Thanks for the hint. I ordered EFM32ZG110F32-QFN24 as soon as you suggested them and they just arrived. Even with shipping and in single they are little more than a buck. 8k version 80 cents. Totally weird pricing schedule. Amazingly almost no difference in price between 1 or 100 pieces and 32k vs 8k.

QFN is not a big problem at all. In fact with a dab of paste and cheap heat gun even easier because there's no soldering iron involved. The 24 pin fit right in place on those generic QFP boards. They look like a very good deal and can't wait to try these out. Now to download some manuals and learn how to program. Thanks again for finding new candidates for the 1$ 1 minute club.
« Last Edit: October 04, 2014, 09:02:56 am by paulie »
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: One Dollar One Minute ARM Development
« Reply #246 on: October 04, 2014, 08:44:01 am »
QFN is not a big problem at all. In fact with a dab of paste and cheap heat gun even easier because there's no soldering iron involved.

Amen to that.  I got one of those OSH Stencils too.  My dev board was the first time I've used many of the SMD packages, with only a few trial runs with TSSOP parts before it.  The whole process went very smoothly.  Had a few solder bridges to clean up due to using too much paste, but that was easy to fix.  The most time-consuming thing was sorting through my parts to find the R and C values I needed.  Definitely makes me think twice about doing through-hole stuff any more than I have to.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #247 on: October 04, 2014, 10:34:45 am »
I wanted to just try to make a QFN deadbug style just to know I could do it.

So I took the wiring diagram and flip it, then flipped and mirror all the labels and components so I could have the bottom view (and changed the label from top view to bottom view).



I wired it up until I got to the XRES, added the decoupling caps and connected the ground with a 22 AWG cable on the other side of the board. Only 9 pins left but I had plenty of GPIOs plus SWDIO/SWDCLK so I attempted to program it before completion.



It powers up and I get regulated 1.8V out of VCCD. I got no shorts but hooking it up to my programmer it doesn't recognize it. Granted, I think I connected 4V by mistake to VCCD instead of VDDD so I might have fried the chip.

On another document I saw that VDDD and VDDA should be shorted, I tried that as well but it just doesn't talk to the programmer via SWD.

I know I can buy 5 boards for a buck or so, but I just wanted to check if I could solder 0.5mm with just one of those third helping hand with magnifying glass, some wire that I have no idea where it came from and my cheap Tenma (Hakko knockoff). I still have 19 of those chips left but the next attempt will be with one of those cheap boards and a skillet.

I stacked the 0.1uF caps on top of the 1uF caps when both where needed.

So right now the only thing this is good for is to regulate from a 1.8V-5.5V unregulated input and get 1.8V regulated output and helped me clear my head while doing it, kind of relaxing since I had no choice but to take my time and work slowly.

The pads on those PSoC4 QFNs are smaller than small.

I consider the result a Fail, but I did enjoyed wiring it up.
 

Offline true

  • Frequent Contributor
  • **
  • Posts: 295
  • Country: us
  • INTERNET
Re: One Dollar One Minute ARM Development
« Reply #248 on: October 04, 2014, 01:18:13 pm »
Thanks for the hint. I ordered EFM32ZG110F32-QFN24 as soon as you suggested them and they just arrived. Even with shipping and in single they are little more than a buck. 8k version 80 cents. Totally weird pricing schedule. Amazingly almost no difference in price between 1 or 100 pieces and 32k vs 8k.
Their pricing shows (especially with typical prices in their propaganda listing them at 100k units) that they only care about very large customers.

The chip is pretty light on peripherals for other chips in this price range, but does have a possibly useful mix (2 timers x 3pwm, but no other high speed or higher resolution timers with interrupts; 1 usart 1 i2c, adc, idac, rtc, pulsecounter and that's about it) but still doesn't seem like a bad choice if what it has will fit your application. I almost picked it for an upcoming project but went to $1 sale PSoC4's instead. Project scope also grew so it's a good thing, I need the extra pins, was considering the G210 as well but the peripherals were too limiting; I also was able to use the UDBs on the PSoC4 for my project to great effect :)

I also have some to play around with - maybe I'll come up with some low power project to use it in.
 

Offline aon

  • Contributor
  • Posts: 30
  • Country: fi
Re: One Dollar One Minute ARM Development
« Reply #249 on: October 04, 2014, 05:07:21 pm »
QFN is not a big problem at all. In fact with a dab of paste and cheap heat gun even easier because there's no soldering iron involved. The 24 pin fit right in place on those generic QFP boards. They look like a very good deal and can't wait to try these out. Now to download some manuals and learn how to program. Thanks again for finding new candidates for the 1$ 1 minute club.

Although