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

0 Members and 1 Guest are viewing this topic.

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #300 on: October 14, 2014, 09:36:08 am »
You can also look at it the other way. This way they get exposed to "how to press the pretty buttons to get code from remote repository to local directory". And before you know it they have their own local repo that they use for their own small projects. Thus helping them organize their own work better than they did in the past with 32485 zip files made at various points in time. Progress allround!

Well, I can always hope.
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #301 on: October 14, 2014, 11:46:15 am »
We'll see how the noob set responds to git get when the next meeting comes up this weekend. Also it would be interesting to see how they respond to the concept of macros. Let's hope westfw will come up with another demo making use of that wonderful feature of GCC asm to show off his neglected macro file.  Maybe combined with some new hardware trick like timers or DMA.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #302 on: October 14, 2014, 12:39:17 pm »
Another idea for a feature to showcase use of assembler: saturating arithmetic. That has the advantage of actually being a borderline real life use case. ;D

Oh oh oh! Better yet, make a delta sigma modulator with the loop filter in asm and using dma to pump out the data. And I'm serious too. :P I actually did part of that (minus the dma) some time ago. And then after evaluation ditched the stm32f4 in favor of fpga because that way it was trivial to get good performance. :P

At any rate, a tight asm based loop with saturating arithmetic is just about the poster child for using assembly. And those hams even get to show off the spectrum analyzer, because higher order delta-sigma modulated PWM displays a lower noise floor than straight up dithered pwm.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4192
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #303 on: October 14, 2014, 03:27:53 pm »
"Saturated arithmetic" with or with without the M4 "dsp" instructions?
None of the current "ghetto" systems (103 (M3), 003 (M0)) has the dsp add-on?
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #304 on: October 14, 2014, 06:19:19 pm »
those hams even get to show off the spectrum analyzer, because higher order delta-sigma modulated PWM displays a lower noise floor than straight up dithered pwm.

Are you volunteering? If so remember that you may be putting westfw out of a job. :)
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #305 on: October 14, 2014, 07:26:44 pm »
"Saturated arithmetic" with or with without the M4 "dsp" instructions?
None of the current "ghetto" systems (103 (M3), 003 (M0)) has the dsp add-on?
Yeah, some of the instructions used I think required cortex-M3 or M4. I didn't really pay all that much attention to it at the time because there was no intention to port it to smaller devices. I see the M0 still has a MUL, but that will not be the goodness of the single cycle multiply-accumulates as found on the M3/M4.

Anyways, all you have to do is write asm for a few years and then cortex-M3 will fit within the $1 requirement. ;)

Are you volunteering? If so remember that you may be putting westfw out of a job. :)
For the asm? Not really. I already evaluated it, and found that 1) for my requirements hand crafted asm did not have any real advantages over compiled C code, and 2) higher order (3 and above) delta sigma was a better fit for fpga's (spartan-6 in this case) than stm32f4's. You run out of registers so fast on those pesky MCUs. :P

But for the delta-sigma part I may do a future write-up. Not sure if there's much interest in it around here. :-//
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #306 on: October 14, 2014, 10:08:09 pm »
You run out of registers so fast on those pesky MCUs.

If you wanna run outta registers real quick program STM8. Reminds me of the old 6502. Almost identical programming model.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #307 on: October 14, 2014, 10:26:05 pm »
Two is more than plenty if you have an accumulator :)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4192
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #308 on: October 15, 2014, 01:24:45 am »
BTW, a quick look on Mouser says that there are over 100 ARM microcontrollers that cost less than $2, in ones.
From at least 5 vendors (SI Labs, ST, Freescale, NXP, Cypress.)  Real prices for 1st line chips from a real distributor.
Digikey has a similar list, and adds the Nuvoton chips...
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1970
  • Country: dk
Re: One Dollar One Minute ARM Development
« Reply #309 on: October 15, 2014, 05:29:52 am »
But for the delta-sigma part I may do a future write-up. Not sure if there's much interest in it around here. :-//

Yes please
And if you release the Arm & FPGA source it would be an extra bonus.

I'm a VHDL beginner , but hope to learn from it.
Have a cheap ep2c45t144 board and a S3E starter , but hoped to use the Altera.

Would like to test it for the EFC on a 10Mhz OCXO , where i would have used a dithered PWM as a DAC.

/Bingo

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4192
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #310 on: October 15, 2014, 05:59:06 am »
I don't know that I'm up to writing mathematical algorithms in assembler.  I have to admit that when some cpu vendor says something like "we've added saturated multiple and accumulate instructions for DSP applications", I have trouble imagining what sort of algorithms they're supposed to help with.  The earliest DSPs were just starting to appear when I graduated from college, but I spent my career pretty far away from "math"...
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #311 on: October 15, 2014, 09:11:41 am »
Two is more than plenty if you have an accumulator :)
For higher order modulators? Not if you want decent performance. Two is more than plenty if you are content with pushing and popping all the time. Actually two is barely adequate even then, because with just two registers you limit yourself to a rather suboptimal subset of instructions. But given your :) at the end I guess you knew that. ;)

Then again, two is more than not nearly enough approaching barely adequate if you have several accumulators, I'll grant you that. Where "several" is equal to or greater than order of modulator. ;)
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #312 on: October 15, 2014, 09:28:33 am »
I'm a VHDL beginner , but hope to learn from it.
Have a cheap ep2c45t144 board and a S3E starter , but hoped to use the Altera.

Would like to test it for the EFC on a 10Mhz OCXO , where i would have used a dithered PWM as a DAC.
Well, it's in verilog, the testbench is in system verilog and I'm using Xilinx parts. But for the rest it's exactly as you wish. ;D

And amusingly enough this whole delta-sigma business started out as a simple PWM DAC. So then you dither it, but it's a bit noisey. And then you wonder "mmmh, well that's a bit noisy, isn't there a better way?". And then it's "mmmh, hey wait a minute, don't delta-sigma modulators shape the noise in pretty shapes?". And then before you know it you have a side project playing with delta-sigma thingies. And then and then and then your time went *poof*.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: One Dollar One Minute ARM Development
« Reply #313 on: October 15, 2014, 10:12:27 am »
I have to admit that when some cpu vendor says something like "we've added saturated multiple and accumulate instructions for DSP applications", I have trouble imagining what sort of algorithms they're supposed to help with.

Well, one use is in filters. If overflows would result in instability then you can use saturation arithmetic to help prevent that. You might get some nonlinearities, but better that than an outright oscillator.

Anyways, for this case I found it to be easier to just use a model that was proven to be stable. Or rather, proven that a stable configuration exists. And then the actual probably-stable configuration is conjured up out of optimization, simulation and a "Yeah, that'll probably do" proclamation.

For those interested, the delsig toolbox really helps with the above conjuration.

I mostly concentrated on the CIFB topology, since I found that to be relatively easy to map onto both mcu and fpga. Of course on the mcu it's a big loop and on the fpga it's a pipeline, but you get the idea.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: One Dollar One Minute ARM Development
« Reply #314 on: October 15, 2014, 03:11:43 pm »
Oops.  The existing .ld file has an incorrect RAM amount

Did the GCC dudes make a mistake or did I pick the wrong one?
The gcc-arm-embedded toolchain is perfectly fine.
If they say this ld is for a generic ARMv7M then that is exactly what they mean. Same applies to ld's for ARMv7A, R and qemu, also available there.
If you want startup code, system init and linker scripts for your specific uC, you have to write/tweak your own ones or copy those three files from vendor's gcc examples. I suggest picking the former method for ld and startup (templates for various architectures available in gcc-arm-embedded toolchain) and the latter for system_init.
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #315 on: October 15, 2014, 11:00:16 pm »
This is bare metal assembler here so no startup or init code in any of the programs in post #1.

Out of several thousand users of the original Basefight multicopter project only 2 or 3 actually got involved with the compile process.  Everybody deals strictly with hex files there. Unlike the Arduino Multiwii it was ported from, the relatively hostile ARM toolsets are too big a jump. Not being the brightest bulb on the Christmas tree I decided to give compiling a go myself. There was virtually zero support so I copied the LD file from a C blinky template. No luck with Baseflight so I moved on to Harakiri changing the 64k to 128k. No luck with Harakiri either so ARM toys were shelved for couple months until the Ham club demo.

The STM32.LD worked fine for all the programs here unitl westfw decided to chew up all the RAM for vectors and who knows what else. This uncovered the error. Changing the 8k to 20k fixed that so until something actually stops working this is the script for now,
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #316 on: October 16, 2014, 02:39:53 pm »
Based on a request for a register symbol table for STM8 asm I've attached a .H file to the page one post. It's derived from the ST programmers reference document so should be accurate. I only spend a few minutes on it so be careful. The C compiler one from reply slot #5 had several incorrect addresses. I only fixed the ones needed for my C demo to work so might be a good idea to redo that from this asm version since it's more dependable.

ps. Here's a snippet showing some of the more useful entries:

Code: [Select]
;stm8.h    from DM00024550.pdf

PD_ODR equ $500F ;Port D data output latch register 0x00
PD_IDR equ $5010 ;Port D input pin value register 0xXX(1)
PD_DDR equ $5011 ;Port D data direction register 0x00
PD_CR1 equ $5012 ;Port D control register 1 0x02
PD_CR2 equ $5013 ;Port D control register 2 0x00
...
UART1_SR equ $5230 ;UART1 status register 0xC0
UART1_DR equ $5231 ;UART1 data register 0xXX
UART1_BRR1 equ $5232 ;UART1 baud rate register 1 0x00
UART1_BRR2 equ $5233 ;UART1 baud rate register 2 0x00
UART1_CR1 equ $5234 ;UART1 control register 1 0x00
UART1_CR2 equ $5235 ;UART1 control register 2 0x00
UART1_CR3 equ $5236 ;UART1 control register 3 0x00
...
CLK_SWR equ $50C4 ;Clock master switch register 0xE1
CLK_SWCR equ $50C5 ;Clock switch control register 0xXX
CLK_CKDIVR equ $50C6 ;Clock divider register 0x18
CLK_PCKENR1 equ $50C7 ;Peripheral clock gating register 1 0xFF
...
ADC_DB1R equ $53E0 ;ADC data buffer registers 0x00
ADC_DB2R equ $53E1 ;ADC data buffer registers 0x00
ADC_DB3R equ $53E2 ;ADC data buffer registers 0x00
ADC_CSR equ $5400 ;ADC control/status register 0x00
ADC_CR1 equ $5401 ;ADC configuration register 1 0x00
ADC_CR2 equ $5402 ;ADC configuration register 2 0x00
...
« Last Edit: October 22, 2014, 06:12:30 pm by paulie »
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #317 on: October 19, 2014, 09:21:37 pm »
Another productivity enhancement. A new A.BAT is upload to the second post that not only compiles but automatically flashes and runs the user program with a single key. In recent benchmark tests this method was found to be several times faster developing code than a couple of the common graphic IDE environments.

Here's a peek:

Code: [Select]
arm-none-eabi-as -mcpu=cortex-m3 -o t.o t.s
if errorlevel 1 goto bad
arm-none-eabi-ld -Map t.map -T stm32.ld -o t.elf t.o
if errorlevel 1 goto bad
arm-none-eabi-objdump -d t.elf > t.lst
arm-none-eabi-objcopy -O ihex t.elf t.hex
\stmflash\stmflashloader -c --pn 5 -Dtr --Hi -i STM32_Med-density_64K -e --all -d --fn t.hex -r --a 0x8000000
:bad
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #318 on: October 22, 2014, 05:42:35 pm »
I came up with a small imrovement to the batch file that allowed me to win the "STM32 CLI/GUI Smackdown" last weekend (actually easy because only one other guy besides me champions cli, LOL). Moving the DTR command outside to a separate line eliminates the need for Arduino type circuit or hitting reset to download again. Also note the BOOT/RUN and reset switches are no longer required. Cuts a few seconds off the edit/assemble/run loop. That works with C too. Here's the secret to share now that the competition is over:

Code: [Select]
arm-none-eabi-as -mcpu=cortex-m3 -o t.o t.s
if errorlevel 1 goto bad
arm-none-eabi-ld -Map t.map -T stm32.ld -o t.elf t.o
if errorlevel 1 goto bad
arm-none-eabi-objdump -d t.elf > t.lst
arm-none-eabi-objcopy -O ihex t.elf t.hex
\stmflash\stmflashloader -c --pn 5 -Dtr --Hi
\stmflash\stmflashloader -c --pn 5 -i STM32_Med-density_64K -e --all -d --fn t.hex -r --a 0x8000000
:bad

ps. In case I forgot to mention it in the other post you do 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".
« Last Edit: October 24, 2014, 04:53:17 am by paulie »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4192
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #319 on: October 22, 2014, 11:52:57 pm »
Quote
the BOOT/RUN and reset switches are no longer required.
Wait...  What did you do?  I've been hating the boot sequence on my board (set BOOT0, reset, download, unset BOOT0, reset again), but I've been resigned.  Don't you need at least two additional connections from the serial port to do some sort of auto-reset?
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #320 on: October 24, 2014, 04:12:22 am »
At least one additional serial connection: DTR.  As shown in the photos from page one BOOT0 stays jumpered. The point is it's not necessary to poke at the target board every time anymore. Because of rare but possible bootloader initialization and I/O state dependencies it is a good idea to disconnect all development cables and test it stand alone before calling it ready for prime time.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: One Dollar One Minute ARM Development
« Reply #321 on: October 24, 2014, 05:45:41 am »
(..)In recent benchmark tests this method was found to be several times faster developing code than a couple of the common graphic IDE environments.
With my SplitCode whole [recompile+program+start debugging] cycle lasts under 3 seconds and that timing does not depend on the application size much (similar timings for development of 1kB or 1MB application).
With single click, under Eclipse, of course.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4192
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #322 on: October 28, 2014, 07:16:51 am »
BTW, it's come to my attention that the Leaflabs "Maple" board (one of the first attempts an an ARM-based Arduino compatible) was based on the STM32f103, and in fact some of the cheap 103 boards you can buy are "Maple Mini" clones.
It looks like the Maple software effort has been largely abandoned, but combining their last efforts with the new Arduino IDE framework (which is more flexible WRT upload/compile/etc scripting) should be possible, giving one the ability to run many Arduino sketches on arbitrarily simple STM32f103 boards.

Efforts in that direction might be more worthwhile than continued work on assembler stuff...
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #323 on: October 29, 2014, 05:52:16 pm »
Truly an excellent idea. The asm does get old quickly for serious development. Strangely Maple boards are even cheaper than the Ebay "blue" boards but 103cb chips cost several times more 103c8. Since these two chips are drop in identical except for ID porting libraries should be trivial. Unfortunately Maplelabs appears to have abandoned Wintel development in favor of Linux/Mac which effectively relegates this to laboratory curiosity status.

I do have one of the Maplemini clones and as soon as you finish off your One Minute PC version I'm certainly on board. :)
 

Offline paulieTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: One Dollar One Minute ARM Development
« Reply #324 on: November 04, 2014, 11:34:18 am »
So i gave Maple's development package a try with less than promising results. I do have a genuine Maplemini but couldn't get it to work at all. I wonder if anybody has ever succeeded in installing or running the blinky?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf