Thursday, August 20, 2009

The GoodFET's MSP430 Stack Depth

by Travis Goodspeed <travis at>

Today I'm stranded in Munich and unable to walk, so I thought it neighborly to measure the stack depth of the GoodFET's firmware in order to determine the minimal microcontroller necessary, reducing the material cost of each unit. This article ought to help those who wish to do the same.

The MSP430F1612 ($15 to $11) that I presently use is rather expensive, and a smaller, cheaper chip will likely suffice. While I don't expect the code to fit in the MSP430F2013 ($3 to $1.50), it's not unreasonable to assume that something like the MSP430F2274 ($5 to $3) would be a good choice.

To determine whether the Flash is sufficient is easy, as I can measure that by the size of the output image. make install reveals this to be 7566 bytes as of r79, which will comfortably fit in the MSP430F2254 (16KB) and 2274 (32KB) and doesn't come close to filling the 1612's 55KB of Flash.

Determining RAM usage is much more difficult, and likely better to be done in actual use than in simulation or by static analysis. I'm implementing this by adding two new commands to the Monitor application. The first, RAM_PATTERN (0x90), fills all of RAM with 0xBEEF, suiciding and resetting at the end. The second, RAM_DEPTH (0x91), measures how large this block of memory is. By running the first, then running several test cases, then running the second, I can accurately measure RAM usage, estimating the minimum required chip for the GoodFET firmware. RAM_PATTERN cannot simple be run at start because the GoodFET restarts each time a client connects.

RAM_PATTERN must know the entry point of the application in order to reset, as well as the start and end addresses of RAM. No care need be taken to avoid damaging the stack or global variables, as a reboot will obliterate and repopulate them anyways.

Looking at the linker script (trunk/firmware/ldscripts/161x.x), it can be seen that the RAM region is defined by data (rwx): ORIGIN = 0x1100, LENGTH = 0x1400, so it extends from 0x1100 to 0x2500. RAM_PATTERN simply writes 0xBEEF over this region, then calls asm("br &0xfffe") to reboot. Don't forget your pointer arithmetic: ++ on a pointer increments by the word size (2), not the integer address (1).

In any case, once these functions are working, it's a simple matter to measure RAM usage. As we know that 0x1400 bytes are available, we can fill with the pattern, then restart, then run code, and compare the number of available bytes. By the following log, you can see that 0x12b2 bytes are unused by the GoodFET firmware even after running the Chipcon test cases, or that 0x1400-0x12b2=0x14E=334 bytes of RAM are necessary.

petite% goodfet.monitor ramfill
petite% goodfet.monitor ramdepth
0x12c4 RAM bytes free.
petite% goodfet.monitor test
Performing monitor self-test.
Self-test complete.
petite% test >>/dev/null
petite% goodfet.monitor ramdepth
0x12b2 RAM bytes free.

Rounding that 334 byte measurement up a bit, it still ought to fit in the MSP430F2254's 512 bytes of RAM, with a pin-compatible upgrade available for the 2274 with 1 kilobyte of RAM. For comparison, the present hardware has 5K of RAM with the MSP430F1612 and 10K with the 1611.

Note that this lean behavior is only possible because the GoodFET's firmware is very flat and uses no dynamically allocated buffers. I will be running some more tests, and if they turn out to my liking, there's a good bet that the MSP430F2274 will be the basis of the GoodFET30.

Firmware compatibility between the two chips will require more creativity than the present scheme of a wacky linker script, as they are of different families. Seeing as how plenty of memory is left over, I could write firmware which identifies its host system and configures the I/O ports so as to run on either system from a single image. I don't think that I will do this, as incompatibilities in the I/O port choices would require complication of all I/O routines that could better be handled by preprocessor directives.


Travis Goodspeed said...

I've added preliminary UNTESTED support for the F2618 chip to svn, as the 2618 has compatible pads with the 1612. If any brave soul assembles such a FET, compile like so:
cd trunk/firmware
mcu=msp430x2618 make -e clean install

Expect kinks to be worked out by the end of the week, and a 2274 FET in the near future.

Richard Majece said...

I know that in that case you have to write a good speech. I even know that it will help you to ask someone to Write My Speech if you need

Jim Rhodes said...

I haven't been to Munich before. But I've been using these paraphrasing tools for a while. You should check them out too!

Jatin Sethi said...

What's more the clinical and physical assessments, patients of liquor rehab focuses by and large experience a 24-hour therapeutically administered detoxification and withdrawal period. During this period, the patient is compelled to abandon liquor. For some, patients adapting to liquor fixation, this might be the longest time they have abandoned liquor in numerous years
beating addiction quotes
drug addiction recovery quotes

Jatin Sethi said...

The site is getting more than 16 million visits for every month in its current sign, yet you may have known YesPornPlease by one of its past names. It was CEPorn, by then VE-Porn, trailed by VEPorn. They've never had an irresistible name, and their header in spite of everything calls it FXPorn. Despite their gross clumsiness at naming the site, they've made sense of how to prop it up for quite a while. YesPornPlease directly has around 30,000 sex movies arranged to stream to no end.

onlineAssignmenthelp said...

While exploring the subjects, the students get brief ideas about the topics and practice writing, which will help them in examinations. The deadline which comes with the assignments allows students to manage time as well. It helps in making students punctual and upgrades skills of time management in academics. Level 5,121 Castlereagh Street Sydney, NSW 2000 whatsapp +61-280-062-221 info@thetutorshelp.comSeemore-

Unknown said...

Cat 3 Combinaison Type 5/6 blanche
COMBINAISON avec coutures couvertes
Housse de protection en SMS non tissé avec chevilles, visage, poignets et taille élastiqués pour ajuster la taille. Egalement avec rabat auto-adhésif pour une meilleure fermeture par l’avant.
Type 5 & 6 avec conformité totale à la classification selon EN 14325
Matériel: SMS 100% Polypropylène 50 g / m2
Couleurs disponibles: Blanche
Taille: XL-XXL
Emballage: 50 Pièces Combinaison jetable

custompackagingexpert said...

Now you won’t have to worry about missing out on great opportunities aiwah to shop online. We are there to help you in aligning your shopping spree the right way!

igoal88 said...

Thank you for sharing this website. It is very useful and valuable. I like your website very much.
igoal slot

mygreatfest said...

Assignment forms the basis of academics. These are the tasks given to the student to make him/herself responsible as a part of the educational system. This blog is very informative and also if you want more information on HOW TO MAKE A GAY GUY FALL IN LOVE WITH YOU then this source is really helpful.

SEO Burner said...

If you are looking for a classic and versatile piece of outerwear, then a mens leather varsity jacket is a great option. It is a stylish and fashionable choice that will last for years.

Mobile app development company said...

Wonderful post. Thanks for sharing this amazing article. I would like to share information about appconsultio, our mobile application development company is more than just lines of code; we are the architects of innovation. Partner with us to embark on a journey where your concepts transcend limitations and become vibrant, intuitive, and indispensable mobile realities.

Mike Rooney said...

I really enjoyed this site.
Jack Torrance Corduroy Jacket

CV Writing Services said...

Unlock your career potential with our professional CV writing services Ireland. Our experienced team of writers crafts tailored resumes that highlight your unique skills and experiences. We understand the Irish job market and can help you stand out from the competition. Whether you're a recent graduate or a seasoned professional, our CV writing services will ensure your document gets noticed by employers. Invest in your future today with CV Writing Services Ireland.

The Bride Side said...

For your wedding day in enchanting Edinburgh, entrust your tresses to the city's top-notch hairstylists who specialize in creating bridal looks. From the historic cobblestone streets to the picturesque landscapes, your Wedding Hair Edinburgh deserves to be as breathtaking as the surroundings. Edinburgh's renowned salons offer a blend of timeless elegance and contemporary flair, ensuring your hairstyle complements your personal style and the overall ambiance of this charming city.

Whether you envision a classic udo, loose waves, or a bohemian braid, Edinburgh's skilled hairstylists will work their magic to make you feel like a radiant bride on your special day.

Mike Rooney said...

I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!

David Puddy 8 ball jacket