Just another "I need a program for ARM without ASF"

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I am targeting an SAM D11, right number of I/Os, in small package (20 ball WLCSP), just not quite enough Flash...

Initially, I created an ASF configuration with USB, SPI, SSD1306 OLED display, Timer, and GPIOs. (It was WAY too big for the flash.)

 

I now have an ASF USB configuration, to which I added my own GPIO, Timer, and SPI routines (along with some of the Adafruit SSD1306 library). With "almost" everything implemented it is compiling to 100.0%. Yup 16384 bytes flash and 87% sram (which I have not yet optimized). I have stripped out some of the USB to the point that anything I now touch causes it to fail. I just need a few more switch cases for handling USB out reports from the host.

 

Is there another option? (The ATmega32U2 in the QFN32 is 4x larger size, which is a major problem.)

 

I am using the SAM D11 Xplained Pro with the OLED1 Xplained Pro for development. I have not yet tackled rolling my own USB as the SPI register configuration was headache enough! Nor have I looked into assembly optimization. (I am considering a reduced character set for the OLED.)

 

So I just thought I would ask before I enter the black hole, if anyone had implemented a USB on the D11?

 

Thanks

 

This topic has a solution.

David (aka frog_jr)

Last Edited: Thu. Jul 7, 2016 - 04:52 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Here is pretty minimal implementation of USB HID for D21 (also works on D11) - https://github.com/ataradov/dgw

 

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you still using ASF for the clock setup?  That's pretty good-sized (~1k, IIRC), and likely to be "necessary" for USB?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No ASF anywhere. All clock setup is done in sys_init() in main.c.

 

No need to involve bloatware for 20 lines of code.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BTW, the whole thing including USB HID, I2C master and some debug UART stuff compiles into ~4K.

 

Edit: clock initialization is 128 bytes exactly.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

Last Edited: Thu. Jul 7, 2016 - 12:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i meant the original poster's code, who was using ASF USB.  Which probably uses ASF calls to get clock info, which only the ASF code would write.

I've used and looked at enough "alexru code" to know that it will be tight and efficient!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@alexru, Thanks, I'll look at the code tomorrow. I'm sure it will be MUCH better than ASF and better than anything I cobble together...

 

@westfw, I have reduced some of the ASF clock routines where unnecessary options are passed, but I'm sure there are more places that could be further optimized.

 

I also have not (as yet) looked at the asm to see if the compiler produced "stupid code" (because I wrote "idiotic C").

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Wow! Thanks Alex.

I have my project (pretty much) up to the point where I was yesterday afternoon (when I had 100.0% flash usage) and my current compile is saying:

        Program Memory Usage  :  8112 bytes   49.5 % Full
        Data Memory Usage     :  2528 bytes   61.7 % Full

So I have used less than half of the Flash as the ASF implementation and 25% less sram!

 

 

Just for fun, I decided to check the size of a bare minimum implementation doing a File/New Project and a File/New Atmel Start. Essentially, I just created a project with no features and main() just containing a while(1); loop.

 

Using: File/New/Project/GCC C Executable Project/ SAMD11D14AM
        Program Memory Usage  :  2008 bytes   12.3 % Full
        Data Memory Usage     :  2128 bytes   52.0 % Full

(Makes me wonder, "Just what is an empty project doing?")

 

 

Using File/New/Atmel Start Configurator

    Create New Project/ATSAMD11D14AM/ Create New Project/Export Project/Download Pack
    File/Import
        Program Memory Usage  :   892 bytes    5.4 % Full
        Data Memory Usage     :  1128 bytes   27.5 % Full

 

(YMMV)

 

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

frog_jr wrote:

Just for fun, I decided to check the size of a bare minimum implementation doing a File/New Project and a File/New Atmel Start. Essentially, I just created a project with no features and main() just containing a while(1); loop.

Well, I also happen to have simple starter projects - https://github.com/ataradov/mcu-...

 

Project actually sets up LED and a button, prints things into UART, reads button, blinks the LED on timer (using interrupts). Size of the SAM D11 one:

Quote:

   text    data     bss     dec     hex filename
    660       0       0     660     294 build/Demo.elf
    660       0       0     660     294 (TOTALS)

 

To be fair to ASF memory consumption (RAM), its linker files are very poorly written. They reserve a chunk of RAM for stack instead of simply leaving the remaining memory. So I guess 2048 bytes of the RAM size in the first example is just a stack space reservation. Something you need to keep in mind with my linker scripts.

 

And just for the record, here is the size of while (1) loop:

Quote:

   text    data     bss     dec     hex filename
    208       0       0     208      d0 build/Demo.elf
    208       0       0     208      d0 (TOTALS)

This is mostly interrupt table, of course.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

Last Edited: Thu. Jul 7, 2016 - 06:42 PM